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));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…