0

I am trying to work with Twilio autopilot which trigger the twilio function after gathering some words, I need program to play digits or 'DTMF tone'

I have written code in javascript in Twilio Function as

exports.handler = function(context, event, callback) {

const VoiceResponse = require('twilio').twiml.VoiceResponse;
const response = new VoiceResponse();
response.play({
    digits: '3'
});


console.log(response.toString());
  callback(null, response);
};

as this code the Twilio function generates the XML (TwiML) file, but if triggered by an autopilot it shows following error

Invalid Autopilot Actions JSON: Invalid Autopilot Action Possible Causes Actions JSON does not comply with the Actions Schema (https://carnelian-neanderthal-8008.twil.io/assets/ActionsSchema.json)

Possible Solutions Test your JSON response against the Actions Schema (https://carnelian-neanderthal-8008.twil.io/assets/ActionsSchema.json)

By this error I am guessing autopilot needs only .json for execution. Should I try any other way.

Any suggestions?

iCrus
  • 1,210
  • 16
  • 30
Chetan
  • 41
  • 5

1 Answers1

0

Twilio developer evangelist here.

Autopilot is designed to take input from humans and respond to them in text or voice, so it doesn't handle playing DTMF tones.

Autopilot also doesn't respond to TwiML, instead it takes JSON encoded actions.

You might consider using <Gather> with input="speech" to listen to a message then respond with <Play> using digits. But this will be outside of Autopilot. You can use TwiML to play DTMF tones until you want to pass on to an Autopilot assistant by responding with the <Autopilot> element.

Let me know if that helps at all.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Thank you so much @philnash, I made a sample code using python but I am figuring out how to detect the IVR finish its sentence and waits the user to input in time window also Gather(input='speech', hint="press one", action="/completed") to trigger action to press 1 'dtmf tone' I am really sorry but I knew flask only a little. – Chetan Oct 25 '19 at 06:10
  • That looks like it will work, are you still having problems? – philnash Oct 25 '19 at 06:11
  • Yes,Please how can I detect IVR finishes its sentence and wait for input in Gather? – Chetan Oct 25 '19 at 06:14
  • Gather has `timeout` and [`speechTimeout` attributes](https://www.twilio.com/docs/voice/twiml/gather#speechtimeout) that you can use to tell it how long to wait after the user has spoken before moving on to the `action` URL. You can set that time in seconds, or with `speechTimout` to "auto" which will attempt to send the result to the `action` as soon as the caller finishes speaking. – philnash Oct 25 '19 at 06:16
  • Yes I will try to figure it out, thank you for suggestion, I will let you know as soon as working solution is created – Chetan Oct 25 '19 at 06:21
  • 1
    really sorry for late posting,setting sppechTimeout and action verb with gather really worked for me – Chetan Nov 07 '19 at 04:04