Twilio Integration
warning
This documentation page is still being written.
The playground supports direct integration with Twilio Voice.
Endpoints
To connect your playground bot to Twilio Voice, use the following webhook URL:
https://api.roboself.com/twilio/voice/BOT_NAME
The method should be set to POST
.
Voice configuration
To configure the voice and the language, you must set the following context variables in your data.yml
file:
twilio:
voice: "Polly.Matthew-Neural"
lang: "en-US"
Check the supported voices here.
Events
The integration will generate two events in the context of the conversation:
new call
: when the call is initiated.call ended
: when the call has finished.
You can use the new call
event to trigger the welcome behavior for your bot:
define flow new call
"""When a new call is initiated, we treat it as if the user says hi."""
event new call
infer user express greeting
tip
This behavior is already included in the co/welcome model.
In the case of the call ended
event, bear in mind that the call has already ended, so, any additional bot messages, after the event, will not be received.
Speech To Text
When the bot needs to wait for user input, it will use TwiML Gather. You can override supported Gather attributes by specifying the twilio_config
parameter on the last bot utterance before waiting for input. The supported attributes are:
Attribute | Description | Default value |
---|---|---|
input | dtmf , speech , dtmf speech | dtmf speech |
enhanced | Whether to use the enhanced model. | true |
speechTimeout | Time to wait before stopping to listen (in seconds). | auto |
speechModel | default , numbers_and_commands , phone_call | phone_call |
language | The language and locale. | en-US |
hits | Comma separated list of words or phrases. | "" |
For example, to optimize the model for numbers input, you can use the following:
some_flow:
...
bot "What is your PIN?"
set $twilio_config to
speechModel: "numbers_and_commands"
speechTimeout: 5
hints: "1234, the PIN is 0000, 0, 1, 2, 3"
tip
You can reuse a specific twilio configuration by storing it in a global context variable.
twilio_pin_input:
speechModel: "numbers_and_commands"
speechTimeout: 5
hints: "1234, the PIN is 0000, 0, 1, 2, 3"
some_flow:
...
bot "What is your PIN?"
set $twilio_config = $twilio_pin_input