用例是使用twilio中的可编程语音调用IVR系统。根据IVR问题,使用twilio函数和TWIML发送答案。我怎样才能做到这一点?到目前为止,我已经使用Twilio进行了调用,并在回调webhook下面进行了调用。
[HttpPost]
public TwiMLResult Index(string message)
{
var response = new VoiceResponse();
var gather = new Gather(input: new List<Gather.InputEnum>()
{
Gather.InputEnum.Speech
} ,
timeout: 5, action:new Uri("https://url-sample/GatherSample"));
gather.Say("Please press 1 or say sales for sales.");
response.Append(gather);
LogWriter.Debug($"Message : {response.ToString()}");
return new TwiMLResult(response);
}
也是Twilio功能代码。
exports.handler = function(context, event, callback) {
const twiml = new Twilio.twiml.VoiceResponse();
const command = event.SpeechResult.toLowerCase();
twiml.say(`You said ${command}. I'll give you a ${command} fact.`);
callback(null, twiml);
};