Play dynamic text or audio from URL in connect applet
Video
What is usual?
Typically, while configuring your Connect applet, you would enter the text or upload the audio that you want your agents to listen before the call gets connected to the customer. This is static in nature - ie, all your agents will hear the same message / audio.
How to make it dynamic?
In Exotel, you have an option to make this dynamic - ie, you can potentially play a different greeting to each agent.
In the Connect applet, you can specify a URL (instead of a static text) in the "Read text like a robot" option. See below.
Choose this option if you want to control playback for each user uniquely
Choose this option if you want to have a static playback
When the option is chosen for URL, Exotel will make an HTTP GET request to that URL (which is hosted at your server). Your server can now return either a text or a URL (to an audio file). If it returns a text, the text will be converted to audio using our Text-To-Speech (TTS) engine and then played out.
The applets mentioned above are a part of the Custom App section also called App Builder, to know more about App Builder please follow----> Exotel App Builder
HTTP Request from Exotel (to your URL)
The GET request that Exotel makes to the URL will have the following query parameters:
HTTP Response from your web server
Your webserver
MUST set the Content-Type HTTP header to 'application/JSON and nothing else.
MUST support a HEAD request from Exotel and return the exact same headers that it would for a GET request.
The response will look something like
{
"start_call_playback":{
- "playback_to":"both",
"type":"audio_url",
"value":"http://...mp3..."
OR
"playback_to":"both",
"type": “text”,
"value": "hello, this is a sample text"
- OR
"playback_to":"callee",
"type":"audio_url",
"value":"http://...mp3..."
OR
"playback_to":"callee",
"type": "text",
"value": "hello, this is a sample text"
}
“in_call_playback:{
“start_delay”:5,
“repeat_frequency”:10,
“play_to_callee”:true,“play_to_caller”:false,
“type”: “audio_url”,
“value”: “http://...mp3”
OR“type”: “text”,
“value”: “hello, this is a sample text”
}
“end_call_playback”:{
“type”: “audio_url”,
“value”: “http://...mp3”
OR“type”: “text”,
“value”: “Hello, this is a sample text”
}
}
One can choose to give only start_call_playback or in_call_playback or end_call_playback and accordingly the audio will be played to users
NOTE
If the customer backend fails to respond to the GET request and Exotel receives 4xx or 5xx responses, then the audio will not be played to the user, and Connect applet will proceed and patch the call between callee and caller
The Audio files MUST be in the .wav/.mp3, 8Khz Mono format. The bit depth must be 16-bit.
NOTE: All other formats are not supported (like 16Kz Mono/Stereo etc)
Caching of the audio files
Exotel caches the audio files that it downloads and plays - so that the next time you send the same file, we don't need to download and it will be faster.
Exotel caches the file based on the name of the URL. So in case you are changing first-audio.wav, you will need to send in another name the next time (Ex: http://example.com/first-audio-new.wav)