【发布时间】:2021-11-18 22:31:34
【问题描述】:
我希望能够向一个号码发送一个 Sid,并让用于该号码的函数检索该 Sid 的信息。具体来说,我希望能够检索该特定 SMS 消息(由 Sid 确定)的“发件人”电话号码。除了从 fetch 调用中得到的 AccountSid 和 Sid 之外,我似乎什么也得不到。
到目前为止我所拥有的(为了简化这个问题而进行了修改):
exports.handler = function(context, event, callback) {
var Sid = event.Body;
let client = context.getTwilioClient();
// without the 'fetch()' it gets only the AccountSid and Sid, with the 'fetch()' it doesn't seem to get anything?
let promise = client.messages(`${Sid}`).fetch();
var x;
console.log(promise);
// saw that it was returning a promise with the fetch so tried to use it here somehow, but nothing returned or worked
promise.then(m => {
x = m;
});
console.log(x);
// do something, create a response message and send
callback(null, twiml);
};
为了获取带有“sid”的消息的详细信息,我做错了什么或需要做什么?
【问题讨论】:
标签: node.js twilio twilio-api twilio-twiml