如何更改友好名称通知 twilio 短信

发布于 2025-01-19 10:10:24 字数 3173 浏览 2 评论 0 原文

我遇到一些问题,我想更改发件人的姓名。我的意思是,可以分配一个字母数字发件人 ID,我查看了文档并遵循了指南,在 twilio api 的响应中,名称出现,但在我收到的消息中,它会将它们发送到相同的号码。我知道这不是国家规定造成的,因为根据 twilio 文档,这是可能的。 (https://support .twilio.com/hc/en-us/articles/223133767-International-support-for-Alphanumeric-Sender-ID)发生了什么?我该如何修复?我需要做任何配置吗?

输入图片此处描述

我希望如何查看发件人 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
        }
    }

但是,在我尝试更改发件人身份的两种方法中,这两种方法都不允许我这样做,这就是我来到这里的原因,我真的需要帮助,这是我需要满足的要求,但我找不到方法帮我。

I am having some problems, I want to change the name of the sender. I mean, it is possible to assign an Alphanumeric Sender ID, I reviewed the documentation and followed the guidelines, in the response of the twilio api the name goes but when in the messages I receive it sends them to the same number. I know that it is not something due to the regulations of the country because according to the twilio documentation, it is possible. (https://support.twilio.com/hc/en-us/articles/223133767-International-support-for-Alphanumeric-Sender-ID) What is happening? How can I fix? Do I have to do any configuration?

enter image description here

How I want the sender ID to be seen
enter image description here

As I receive the sender ID

enter image description here

UPDATING QUESTION

Ok, the way I have structured the code is as follows:

I am working on a nodejs project, I need to send a message to multiple phone numbers so in order to do it I used the SMS notification service offered by Twilio, this is the method that was created:

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);
        }
    }

The sendSMSAsNotify() method works great, I can send the same SMS to multiple numbers. But now what I want to achieve is that every message I send shows the sender id. I didn't find how to do it in the documentation of the SMS notification service, so I tried to change it and use a very simple method to send SMS via twilio to a single number just for testing.

async sendSMS(sms: SMSDto) {
        try {
            return await this.client.messages.create({
                body: sms.message,
                from: 'MyCompany',
                to: sms.number,
            });
        } catch (e) {
            return e
        }
    }

But in neither of the two methods in which I tried to change the sender identification it did not allow me and that is what brings me here, I really need help, it is a requirement that I need to fulfill and I cannot find a way to help me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萌化 2025-01-26 10:10:24

首先,而 说:

洪都拉斯移动运营商不完全支持动态字母数字发件人ID。发件人ID可以用Twilio平台外的本地长代码或简短代码覆盖。

因此,即使您要在我要解释的情况下设置所有内容,您的发件人ID仍然有可能被本地的长代码或简短代码覆盖,并且Twilio无法对此做任何事情。

话虽这么说,这是为字母数字发送者ID设置的方法。


由于您使用通知发送消息,因此您将设置 Messaging Service 与通知一起使用。

消息传递服务控制了从数字池中从Notify发送SMS消息的方式。该池还可以包含您的字母数字发件人ID,

因此,要从字母数字发件人ID发送,您需要在消息服务中转到发件人池 并添加Alpha发件人。

”将出现模态,在下拉列表中选择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:

Dynamic Alphanumeric Sender IDs are not fully supported for Honduras mobile operators. Sender IDs may be overwritten with a local long code or short code outside the Twilio platform.

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.

On the Sender Pool page, click the button titled "Add Senders"

A modal will appear, choose Alpha Sender in the drop down.

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.

不美如何 2025-01-26 10:10:24

您是否有可能在一个不支持字母数字发件人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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文