【发布时间】:2022-12-03 18:56:39
【问题描述】:
我有一个简单的流程,可以将传入的 SMS 消息发布到 slack。我还有一个功能可以让我发送和接收 SMS 消息。 (即如果短信来自 MY_NUMBER 并且消息以 +12121212 开头:那么它会将消息发送到 +12121212。
如果消息不是来自 MY_NUMBER,它将把 SMS 转发给 MY_NUMBER)
我希望函数触发流程而不是将消息转发到 MY_NUMBER。
我想在函数运行后触发我的流程:
例如
exports.handler = function(context, event, callback) {
const MY_NUMBER = '+0000000000000';
let twiml = new Twilio.twiml.MessagingResponse();
if (event.From === MY_NUMBER) {
const separatorPosition = event.Body.indexOf(':');
if (separatorPosition < 1) {
twiml.message('You need to specify a recipient number and a ":" before the message.');
} else {
const recipientNumber = event.Body.substr(0, separatorPosition).trim();
const messageBody = event.Body.substr(separatorPosition + 1).trim();
twiml.message({ to: recipientNumber }, messageBody);
}
} else { ***MY FLOW SHOULD BE TRIGGERED HERE***
// the above line should replace `twiml.message({ to: MY_NUMBER }, `${event.From}: ${event.Body}`);`
}
callback(null, twiml);
};
【问题讨论】:
标签: javascript twilio slack