Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

How to implement Answering Machine detection using Twiml or twilio JSClient

We are building an in-browser messenger app using Twilio, From JS client we make a call and use Twiml to dial the number, This is our basic flow. I understand from other Questions that AMD is only available for RestAPI, How can I utilise Rest API along with JS client, or How can I Integrate AMD with my current setup. any help/suggestions Please :) . Thanks in advance

question from:https://stackoverflow.com/questions/65913444/how-to-implement-answering-machine-detection-using-twiml-or-twilio-jsclient

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes as far as I know you can't use TwiML to turn on the answer machine detection and you are restricted to using the API.

The API endpoint you want to use is the Call Resource. This is in essence not nothing more than a POST to https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Calls.json and then you set the parameter MachineDetection to Enable (please refer to the docs here).

But this needs authentication in form of your TWILIO_AUTH_TOKEN which you can't expose to any client. I don't know the details of your JS client and how you do authentication & authorisation but I'd suggest you encapsulate the logic in your backend where you can properly secure it. Then you can also use the Twilio helper libraries, e.g. for Python or Node.JS, to place the call (example for Node.JS taken from the docs and adapted):

const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);

client.calls
  .create({
     twiml: '<Response><Say>Hello World!</Say></Response>',
     to: '+1...',
     from: '+1...',
     machineDetection: 'Enable'
   })
  .then(call => console.log(call.sid));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...