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?
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.