如何更改友好名称通知 twilio 短信
我遇到一些问题,我想更改发件人的姓名。我的意思是,可以分配一个字母数字发件人 ID,我查看了文档并遵循了指南,在 twilio api 的响应中,名称出现,但在我收到的消息中,它会将它们发送到相同的号码。我知道这不是国家规定造成的,因为根据 twilio 文档,这是可能的。 (https://support .twilio.com/hc/en-us/articles/223133767-International-support-for-Alphanumeric-Sender-ID)发生了什么?我该如何修复?我需要做任何配置吗?
当我收到发件人 ID
更新问题
好的,我构建代码的方式如下如下:
我正在开发一个nodejs项目,我需要向多个电话号码发送消息,因此为了做到这一点,我使用了Twilio提供的短信通知服务,这是创建的方法:
async sendSMSAsNotify(req: Request, res: Response) {
try {
console.log("req.body:", req.body);
let messageBody = req.body.body;
console.log(messageBody);
let numberList = req.body.toBinding;
let extractBody = messageBody.replace(/<[^>]+>/g, '');
console.log(extractBody);
var decodedStripedHtml = he.decode(extractBody);
//console.log(decodedStripedHtml);
//console.log(`Body: ${messageBody}`);
var numbers = [];
for (let i = 0; i < numberList.length; i++) {
numbers.push(
JSON.stringify({
binding_type: "sms",
address: numberList[i],
})
);
}
const notificationOpts = {
toBinding: numbers,
body: decodedStripedHtml,
title: 'MyCompany'
};
// console.log("numbers:", notificationOpts.toBinding);
// console.log("body", notificationOpts.body);
const response = await this.client.notify
.services(process.env.SERVICE_SID_NTF)
.notifications.create(notificationOpts);
console.log('response', response);
res.json({
msg: `Message sent successfully! ${response}`,
});
} catch (e) {
throw new HttpException(HttpErrors.NOT_FOUND_ERROR, HttpStatus.NOT_FOUND);
}
}
sendSMSAsNotify( )
方法效果很好,我可以将相同的短信发送到多个号码。但现在我想要实现的是我发送的每条消息都显示发件人 ID。我没有在短信通知服务的文档中找到如何做到这一点,因此我尝试更改它并使用一种非常简单的方法通过 twilio 向单个号码发送短信以进行测试。
async sendSMS(sms: SMSDto) {
try {
return await this.client.messages.create({
body: sms.message,
from: 'MyCompany',
to: sms.number,
});
} catch (e) {
return e
}
}
但是,在我尝试更改发件人身份的两种方法中,这两种方法都不允许我这样做,这就是我来到这里的原因,我真的需要帮助,这是我需要满足的要求,但我找不到方法帮我。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,而 说:
因此,即使您要在我要解释的情况下设置所有内容,您的发件人ID仍然有可能被本地的长代码或简短代码覆盖,并且Twilio无法对此做任何事情。
话虽这么说,这是为字母数字发送者ID设置的方法。
由于您使用通知发送消息,因此您将设置 Messaging Service 与通知一起使用。
消息传递服务控制了从数字池中从Notify发送SMS消息的方式。该池还可以包含您的字母数字发件人ID,
因此,要从字母数字发件人ID发送,您需要在消息服务中转到发件人池 并添加Alpha发件人。
一旦您将alpha sender设置在消息传递服务池中的alpha sender设置后,就可以将用于发送您的消息。如果您不打算使用它们,则您甚至可以删除池中有任何长的代码编号,尽管如果您确实发送给不支持字母数字发送者ID的国家,则它们对后备很有用。
First up, while the list of countries that support alphanumeric sender IDs does contain Honduras there are further guidelines for SMS in Honduras that say:
So, even if you set everything up as I am about to explain, it is still possible that your sender ID may be overwritten with a local long code or short code and that Twilio is unable to do anything about that.
That being said, here's how to set up for alphanumeric sender IDs.
Since you are using Notify to send the messages, you will have set up a Messaging Service to use with Notify.
The Messaging Service controls how the SMS messages are sent out from Notify, from a pool of numbers. That pool can also contain your alphanumeric sender ID
So, to send from an alphanumeric sender ID you need to go to your Sender Pool within your Messaging Service and add an alpha sender.
Once you have the alpha sender set in your Messaging Service's pool, it will be used to send your messages out. You can even remove any long code numbers you have in the pool, if you do not plan to use them, though they are useful to fallback to if you do send to a country that doesn't support alphanumeric sender IDs.
您是否有可能在一个不支持字母数字发件人ID ,那个Twilio会倒在一个简短的代码上吗?
PS:如果您可以在问题中添加代码段(显示您运行的代码),将会有所帮助。
Is it possible that you are in a country that does not support alphanumeric sender IDs and that Twilio falls back on a short code then?
PS: It would be helpful if you could add a code snippet, that shows the code you run, to your question.