33
loading...
This website collects cookies to deliver better user experience
rasa init
will be fine)rasa init
to spin one up.credentials.yml
, a file you probably haven't ever touched. We're going to add a configuration that will tell that internal Twilio connector we're going to use it.credentials.yml
file. You can add it above or below the default rest:
and rasa:
config that may already be there.twilio:
account_sid: <copy-paste-your-account-sid-here>
auth_token: <copy-paste-your-auth-token-here>
twilio_number: <copy-paste-your-phone-number-here>
twilio_number
is to just enter the digits, no -
or (
and it does require a leading country code (in the USA that's a 1
) So it should look something like this:twilio_number: 12223334444
credentials.yml
file as welltwilio_voice:
initial_prompt: "hello"
assistant_voice: "Polly.Salli"
language: "en-GB"
reprompt_fallback_phrase: "I didn't get that could you repeat?"
speech_timeout: "1"
speech_model: "default"
enhanced: "false"
inital_prompt
is what will get sent to your Rasa-bot in the background to trigger it. Your bot won't respond unprompted, so this gets things started. If you're using the out-of-the-box default Rasa bot, this will trigger the greet
intent. You can also adjust the response specifically for Twilio using the channel specific variations Rasa allows. I'll touch on that near the end.assistant_voice
is the voice that will be used on the phone when your bot responds. There is a giant list of voices you can choose from, both male and female and from many nationalities. assistant_voice
parameter accordingly. Use the Voice Name from the console (ie. Amy) and if you're using the Amazon Poly voice, add a Polly.
before the voice name like this Polly.Amy
. If you're using the Basic voice, you can just add the name alone, there's no need to prefix it with Basic or anything.language
is easy, just look at the voice list (or the Language code in the speech console) it'll be in the parenthesis ( ) and enter that. The voice names overlap, and some have the same names but different dialects and accents based on the language / nationality.reprompt_fallback_phrase
- this is functionally similar to Rasa's Default Fallback, however it is for Twilio. If for some reason it can't even attempt to understand you, or translate what you said to text, it will speak back this message instead of sending a garbled stream of characters to your bot. Because it is a different configuration you can make it a different phrase than your utter_default
response.speech_timeout
Speech is different than text. When you complete a text message you hit send and the bot knows to process what you've typed. When speaking, the bot doesn't know when you're done, so this timeout is how much silence it will wait for before it attempts to send what you said to your bot. The shorter the time, the quicker response, however if you have someone that talks slow, a 1 second delay could produce a bot that interrupts that person. And if it didn't get the complete phrase it may ask them to repeat it when they never finished it. The flip side to this is that if it is too long, the system feels laggy, even though it's acting properly. I changed mine to 1 second because I talk quicker and when I demo the prototype, I want as little lag-feel as possible.speech_model
This is the model that Twilio will use when performing it's STT (Speech to Text) and TTS (Text to Speech) functions. Values here are limited to default
, numbers_and_commands
and phone_call
. If you read the docs on these settings, default
is best for talking to Rasa, unless of course you're building a number menu tree like many phone systems have in place, in which case you want the phone_call
. If you are speaking short phrases and keywords, choose numbers_and_commands
. These different models are trained up to specialize on the content that is being spoken.enhanced
This allows you to enable (or disable) Twilio's enhanced premium speech transcription (STT) service. This is a very good system and seems to nail the transcriptions better than when it's off. However, this will impact your account balance (costs about 50% more), so for the time being, unless you really have problems with your bot responding to your voice, I'd leave it at false
most of the time. But then again, you have free money, just make sure you don't burn through it before you wow your boss 😉.rasa run -m models --enable-api --log-file out.log --cors "*" --debug
Rasa server is up and running.
ngrok http 50005
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Session Expires 1 hour, 57 minutes
Version 2.3.40
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://f43f711b19b9.ngrok.io -> http://localhost:5005
Forwarding https://f43f711b19b9.ngrok.io -> http://localhost:5005
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
https://f43f711b19b9.ngrok.io
http://127.0.0.1:4040
If you hit that in a browser, you'll see the url's listed, but to get a crazy amount of information about the tunnel, click the status link. We don't need to know any of that for what we're doing but it's good to know it's there though. So back to the setup.>
next to Phone Numbers>
next to Managehttps://f43f711b19b9.ngrok.io/webhooks/twilio_voice/webhook
initial_prompt:
value through Ngrok to your local instance of Rasa. When it does, you'll see the webhook hit Ngrok in the console, and then you'll see your rasa terminal spin like a top (because we launched it in debug mode). utter_greet:
- text: Hello, I am TwilBot. \nPlease let me know how I can help you
\n
and it will say "backslash n". But we want that line break there for our web chat component. So what to do????utter_tell_greet:
- text: Hello, I am TwilBot. \nPlease let me know how I can help you
channel: "twilio_voice"
- text: Hello, I am TwilBot, thank you for calling. Please let me know how I can help you
channel:
with the same indent level as the - text:
response above it, and then having the channel-specific response at that same indent level. At first I thought it was a typo in the docs, but sure enough that's how it should look.rasa run -m models --enable-api --log-file out.log --cors "*" --debug
Rasa server is up and running.
hello
to the number you have setup. It should reply with a message that starts with "Send from your Twilio trial account -". This text will prefix all text messages received from your bot. Obviously it will go away if you upgrade.