如何从传入的 phone 调用 webhook 请求中获取调用者?
How can I get the caller from an incoming phone call webhook request?
我要为 Twilio 中的来电开发一个 webhook:
app.post('/voice', (req, res) => {
const twiml = new VoiceResponse();
const caller = ...;
twiml.say('hello, your number is ' + caller);
res.type('text/xml');
res.send(twiml.toString());
});
如何从请求 (req
) 中获取呼叫者 phone 号码?我不需要名字,只需要号码。
我无法在文档中找到调用 webhook 时 POST 正文中发送的内容。
您要查找的 caller phone number
在 req
对象中。
是req.body.From
。
在你的例子中 const caller = ...;
变成const caller = req.body.From;
.
文档:
请求参数
https://www.twilio.com/docs/api/twiml/twilio_request#synchronous-request-parameters
响应 phone 来电 Node.js
https://www.twilio.com/docs/guides/how-to-respond-to-incoming-phone-calls-in-node-js#write-nodejs-code-to-handle-the-incoming-phone-call
呼叫监控 Node.js
https://www.twilio.com/blog/2015/09/monitoring-call-progress-events-with-node-js-and-express.html
我要为 Twilio 中的来电开发一个 webhook:
app.post('/voice', (req, res) => {
const twiml = new VoiceResponse();
const caller = ...;
twiml.say('hello, your number is ' + caller);
res.type('text/xml');
res.send(twiml.toString());
});
如何从请求 (req
) 中获取呼叫者 phone 号码?我不需要名字,只需要号码。
我无法在文档中找到调用 webhook 时 POST 正文中发送的内容。
您要查找的 caller phone number
在 req
对象中。
是req.body.From
。
在你的例子中 const caller = ...;
变成const caller = req.body.From;
.
文档:
请求参数
https://www.twilio.com/docs/api/twiml/twilio_request#synchronous-request-parameters响应 phone 来电 Node.js
https://www.twilio.com/docs/guides/how-to-respond-to-incoming-phone-calls-in-node-js#write-nodejs-code-to-handle-the-incoming-phone-call呼叫监控 Node.js
https://www.twilio.com/blog/2015/09/monitoring-call-progress-events-with-node-js-and-express.html