简体   繁体   English

在Twilio调用期间更改Twiml指令

[英]Changing Twiml instruction during the Twilio call

I am working an a Twilio app, and now building a feature to change Twiml instruction during the call. 我正在使用一个Twilio应用程序,现在正在构建一个功能来在通话期间更改Twiml指令。

So below will be a use case for it. 因此,下面将是一个用例。

  1. A user calls to a specific number for example 123-456-7890 用户呼叫特定号码,例如123-456-7890
  2. When 123-456-7890 receives and answers the call, it should play some musics. 123-456-7890收到并接听电话时,它应该播放一些音乐。
  3. In a dashboard, I, an agent, should be able to change the music playing with other message instruction by clicking a button. 在仪表板中,我(代理人)应该能够通过单击按钮来更改音乐播放以及其他消息指令。
  4. The replaced message should play until the call ends. 被替换的消息应一直播放到通话结束。

I tried to figure out a way to build this feature, but I wonder if it is technically possible or not. 我试图找出一种构建此功能的方法,但我想知道从技术上讲它是否可行。 Thank you for reading my question. 感谢您阅读我的问题。 It will be really nice if any of you can give me some comments or feedbacks. 如果您能给我一些意见或反馈,那将是非常好的。

Thanks 谢谢

Yes, you can instruct a call to switch to executing a new TwiML. 是的,您可以指示呼叫切换到执行新的TwiML。

You can do that by making a POST reuqest to Twilio's API, call instance resource. 您可以通过对Twilio的API发出POST请求,来调用实例资源。

With curl 卷曲

curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls/CAe1644a7eed5088b159577c5802d8be38 \
    -d "Url=http://demo.twilio.com/docs/new-voice.xml" \
    -d "Method=POST" \
    -u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'

or with Node 或与节点

// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.calls('CAe1644a7eed5088b159577c5802d8be38')
      .update({method: 'POST', url: 'http://demo.twilio.com/docs/new-voice.xml'})
      .then(call => console.log(call.to))
      .done();

Docs: 文档:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM