Search code examples
twiliospeech-recognitiontext-to-speechdialogflow-esvoice

Can twilio Programmable voice be integrated with Google's DialogFlow?


Is there a way to route a voice call to google Dialogflow (or Amazon Lex) ?

sequence:

  1. Call comes into to a number
  2. Twilio sends the voice input to endpoint (DialogFlow)
  3. Text response is received from DialogFlow
  4. Twilio streams voice (text to speech) back to caller

Note: This can be achieved using Google telephony. However, I would like to know if this is possible by using the twilio at the call handling layer ?


Solution

  • Twilio developer evangelist here.

    You could do this using <Gather> with input="speech" to transcribe the caller's speech to text. When the live transcription is complete, Twilio makes a webhook request to the action attribute for the <Gather> with the SpeechResult as one of the parameters.

    You can then send that text to the service you want to use (Dialogflow/Lex), which will respond with the response which you can then put into a <Say> element and respond to the webhook to speak the response.

    If you're interested in building automated response bots like this, you might want to look into Twilio Autopilot which has the speech to text and NLP built in for phone calls and can also be used across messaging platforms and Alexa too.