如何从传入的 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 numberreq 对象中。

req.body.From

在你的例子中 const caller = ...;

变成const caller = req.body.From;.


文档: