我打算在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
)?我不需要名字,只需要数字。
我无法在docs中找到调用webhook时POST主体中发送的内容。
答案 0 :(得分:3)
您要查找的caller phone number
位于req
个对象中。
它是req.body.From
。
在您的示例const caller = ...;
变为const caller = req.body.From;
<强> 文档: 强>