Playing audio files
At any stage of the conversation the bot can play a pre-recorded audio file to the user.
The audio file should be located on a web server (URL) that is accessible to VoiceAI Connect, and should be in one of the supported formats.
How do I use it?
For playing a pre-recorded audio file, the bot should send a playURL
event.
See Sending activities page for instructions on how to send events using your bot framework.
The URL of audio file should be specified on the playUrlUrl
parameter.
When handling the event, VoiceAI Connect will issue an HTTP GET request to retrieve the audio file from this location. In case the URL uses the HTTPS schema, TLS will be used for securing the connection, and the VoiceAI Connect will verify the certificate of the server.
playUrlMediaFormat
parameter; otherwise, the audio is played corruptly.
See below for the supported formats.Example:
{ "type": "event", "name": "playUrl", "activityParams": { "playUrlUrl": "https://example.com/my-file.wav", "playUrlMediaFormat": "wav/lpcm16" } }
{ "type": "event", "name": "playUrl", "channelData": { "activityParams": { "playUrlUrl": "https://example.com/my-file.wav", "playUrlMediaFormat": "wav/lpcm16" } } }
Send event named playUrl
(see Sending event to VoiceAI Connect Enterprise)
{ "activityParams": { "playUrlUrl": "https://example.com/my-file.wav", "playUrlMediaFormat": "wav/lpcm16" } }
[Activity "type": "event", "name": "playUrl", "channelData": ${json(` { "activityParams": { "playUrlUrl": "https://example.com/my-file.wav", "playUrlMediaFormat": "wav/lpcm16" } } `)} ]
For Dialogflow CX, add the "Play pre-recorded audio" fulfillment, as shown in the following example of configuration through the Dialogflow CX user interface:
Using the "Play pre-recorded audio" fulfillment assumes that the file is in wav/lpcm16
format. If the file is in a different format, you can set it by adding a Custom Payload fulfillment with the following content:
{ "sessionParams": { "playUrlMediaFormat": "raw/lpcm16" } }
As an alternative to using the "Play pre-recorded audio" fulfillment, you can also use the VoiceAI Connect playURL
event, by adding a Custom Payload fulfillment with the following content:
{ "activities": [{ "type": "event", "name": "playUrl", "activityParams": { "playUrlUrl": "https://example.com/my-file.wav", "playUrlMediaFormat": "wav/lpcm16" } }] }
Add a Custom Payload response with the following content:
{ "activities": [{ "type": "event", "name": "playUrl", "activityParams": { "playUrlUrl": "https://example.com/my-file.wav", "playUrlMediaFormat": "wav/lpcm16" } }] }
{ "type": "event", "name": "playUrl", "activityParams": { "playUrlUrl": "https://example.com/my-file.wav", "playUrlMediaFormat": "wav/lpcm16" } }
Tips
<audio>
element, if the text-to-speech engine supports it. See Playing text to the user for more details.Event parameters
The following table lists the parameters associated with this event:
See Changing call settings for details on how these parameters can be applied.
Parameter |
Type |
Description |
---|---|---|
String |
URL of where the audio file is located. |
|
Boolean |
Control caching of the pre-recorded audio. Possible values:
|
|
String |
Defines the format of the pre-recorded audio file. You must encode your prerecorded audio file with the selected media format. Possible values:
Note: VoiceAI Connect Enterprise supports
raw/lpcm16_24 and wav/lpcm16_24 from Version 3.24.1 and later. |
|
String |
Defines the text to display in the transcript page of the user interface while the pre-recorded audio is played. |
|
String |
Defines the behavior to be taken in case of failure playing the audio. Possible values:
VoiceAI Connect Enterprise supports this parameter from Version 3.8 and later.
|