The <Answer/> Element

This element answers the incoming call. It is actually not necessary to answer a call because when we execute a Speak, Play, GetDigts, GetInput, SendFax, ReceiveFax, the call will be answered automatically. However, in some cases you might want to actively answer the call so that it gets ready to play a prompt sooner.

Consider this XML:

1
2
3
4
<IVR>
  <GetJSON var="data" url="https://somewhere.com/somedata?calling_number={{CallingNumber}}"/>
  <Speak voice="en-US-Standard-C">{{data.msg}}</Speak>
</IVR>

The Speak element will automatically answer the call but it will also wait for 2 seconds before playing the prompt to compensate for delay to fully open the audio path in the PSTN.

But if you use this instead:

1
2
3
4
5
<IVR>
  <Answer/>
  <GetJSON var="data" url="https://somewhere.com/somedata?calling_number={{CallingNumber}}"/>
  <Speak voice="en-US-Standard-C">{{data.msg}}</Speak>
</IVR>

the call will be answered immediately and then the time spent by execution of GetJSON will be discounted from the time Speak will wait to play the prompt. So for example if GetJSON takes half a second to run, then Speak will wait for just a 1.5 seconds.