Skip to main content

PreAnswer

Definition

The PreAnswer verb responds to the incoming call before it is answered. This is a so-called early media mode: the media is sent to the calling party before the called party answers the call. This is especially useful when you want to play some custom message (e.g., to warn the calling party about some additional costs) so that they can hang up before the conversation actually starts.

You can also use the PreAnswer to set custom ringtones, provide a “ringing” indication, or to speak/play content dynamically while the call is still in an unanswered state.

note

Not all phone numbers support the early media mode. It is not a part of the WebRTC specification, so the phones based on it will fail to playback the content nested inside the PreAnswer verb.

Supported Attributes

These attributes can be used to modify the PreAnswer verb. They are inserted as name-value pairs in the start-tag.

AttributeData TypeDescription
ringing
booleanDetermines the behavior of Pause/Wait verbs that preceed any and all Play and Say verbs.
  • If false (default), Pause/Wait produces 183 Session Progress.
  • If true, leading Pause/Wait produces 180 Ringing.
If a Play or Say verb is encountered, behavior automatically switches to 183 Session Progress to enable early media playback. The default value is false.

Examples

Play a message before rejecting the call

In this example an automatic 'Sorry, we cannot answer your call right now. Please try again later.' message will be played to the calling party and then, after a 4-second pause, a pre-recorded message will be repeated three times. Then the call will be rejected.

<Response>
<PreAnswer>
<Say>Sorry, we cannot answer your call right now. Please try again later.</Say>
<Pause length="4"></Pause>
<Play loop="3">https://storage.carrierx.com/f/5fac56c8-c9fa-4d0e-bf88-f114e0d0cfab.mp3</Play>
</PreAnswer>
<Reject reason="busy"></Reject>
</Response>

Ringing simulation before early media

In this example the call simulates ringing for 10 seconds, then switches to early media to play a greeting, and finally answers the call.

<Response>
<PreAnswer ringing="true">
<Wait length="5" />
<Wait length="5" />
<Say>Hello, we are connecting you to an agent</Say>
<Wait length="5" />
</PreAnswer>
<Say>This is the start of the call</Say>
<Hangup />
</Response>

Behavior:

  • First 10 seconds: 180 Ringing is sent.
  • Greeting plays: switches to 183 Session Progress.
  • After another 5 seconds: call is answered with 200 OK and continues.

Nesting Rules

  • You can nest the Play, Say and Pause/Wait verbs within the PreAnswer verb.
  • You cannot nest the PreAnswer verb within other FlexML verbs.