Skip to navigation
Calling

answer

View as MarkdownOpen in Claude

Answer incoming call and set an optional maximum duration.

Properties

answer
objectRequired

An object that accepts the following properties.

answer.max_duration
integer | stringDefaults to 14400 seconds (4 hours)

Maximum duration in seconds for the call. Also accepts a SWML variable reference (string) such as ${vars.max_call_seconds}, which is substituted when the method runs and must resolve to a valid duration.

answer.codecs
string | string[]

Codecs to offer, as a comma-separated string ("PCMU,PCMA,OPUS") or an array of strings with one codec per entry. Each array entry can also be a SWML variable reference, resolved when the method runs.

Valid codecs depend on the call type:

  • Phone calls: PCMU, PCMA, G722, G729, AMR-WB.
  • SIP and WebRTC calls: all of the above, plus OPUS, VP8, H264.

If the requested codecs aren’t valid for the call type, they’re ignored, a relay_script_method_parameter_invalid_value warning is reported, and answer continues without them.

answer.username
string

Username to use for SIP authentication challenges. Applied only together with a password that isn’t empty after variable expansion.

answer.password
string

Password to use for SIP authentication challenges. When it isn’t empty after variable expansion, it’s applied together with username.

Variables

Set by the method:

  • answer_result: (out) success or failed. success is also set when there was nothing to answer, for example on an outbound call or a call that’s already answered, so it doesn’t by itself mean this method newly answered the call. failed means the answer request for this invocation was unsuccessful.

Examples

No parameters

version: 1.0.0
sections:
main:
- answer: {}

Named parameter

version: 1.0.0
sections:
main:
- answer:
max_duration: 60

Codecs as an array

version: 1.0.0
sections:
main:
- answer:
codecs:
- PCMU
- PCMA

Maximum duration from a variable

version: 1.0.0
sections:
main:
- set:
max_call_seconds: 600
- answer:
max_duration: '${vars.max_call_seconds}'