使用 twilio Passthrough API 向多个号码发送消息

Sending messages to multiple numbers using twilio Passthrough API

我正在使用 twilio 在单个 API 呼叫中向多个 phone 号码发送消息。

client.notify.services(notifyServiceSid)
  .notifications.create({
    toBinding: JSON.stringify([
      binding_type: 'sms', address: '** First phone number here **',
      binding_type: 'sms', address: '** Second phone number here **'
    ]),
    body: 'You just sent your first message with the Passthrough API!'
  })
  .then(notification => console.log(notification.sid))
  .catch(error => console.log(error));

上面的示例代码片段将相同的消息 ('You just sent your first message with the Passthrough API!') 发送到 phone 个数字的数组,尽管我想要做的是向每个 phone 个数字发送不同的消息。上面的代码片段似乎不可能。我在给定的博客中也找不到任何内容:Passthrough API。那么无论如何要向每个 phone 号码发送不同的消息。我还有一个向每个收件人发送不同消息的实现:

const prepareSendingMessages = async (body) => {
    //parse message input and send message in loop
    try {
        console.log(body.data)
        for (const sms of body.data.messages) {
            await sendMessage(sms.to, sms.message)
        }
    } catch (error) {
        console.log(error);
    }

};

const sendMessage = async (to, message) => {
    let messageResult = await client.messages
        .create({
            body: message,
            from: process.env.TWILIO_NUMBER,
            to
        });

    console.log(messageResult);

    return true;
};

但我正在寻找是否可以通过 Twilio's Passthrough API

您为此使用消息资源。

如何发送短信 https://www.twilio.com/docs/sms/send-messages

我想做的是向不同的 phone 号码发送多条消息,而每个 phone 号码包含不同的正文,我有一个选项 Twilio's Passthrough API but the problem here is you can't change the body of messages for individual number. So what I did used Twilio's send-message API, calling API call for each number with different message body for each number. So it is not possible to send multiple messages with single API call while each message containing different body, at least with Twilio's Passthrough API