Twilio 作为一对多 SMS 对话的代理 [英] Twilio as a proxy for one-to-many SMS conversations

查看:22
本文介绍了Twilio 作为一对多 SMS 对话的代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为顾问构建一个小型 SMS 服务.他希望他的客户能够将 SMS 发送到一个 Twilio 号码,然后将它们转发到他自己的电话号码.当他回复时,他希望回复看起来像是来自 Twilio 号码(以便隐藏他的个人号码),并最终与代理 SMS 通信的单个 Twilio 号码保持多个对话.我想我可以使用会话来做到这一点,但我不完全确定如何实现它?

I'm building a small SMS service for a consultant. He wants his clients to be able to send SMSs to a single Twilio number, and have them forward to his own phone number. When he responds, he wants the responses to appear to be from the Twilio number (so as to conceal his personal number), and ultimately maintain multiple conversations with a single Twilio number proxying the SMS communication. I imagine I can do this using sessions, but I'm not entirely sure how to implement it?

有什么好的方法吗?

推荐答案

Twilio Evangelist 在这里.

Twilio Evangelist here.

这实际上有点棘手,但您有几个选择.主要问题是您需要将来自 Twilio 号码的 SMS 消息发送给顾问,但这可能包含多个对话.Twilio 将保留会话/cookie 等,但仅对两个数字唯一.由于 SMS 没有任何允许您添加任何额外元数据的内容,因此您需要查看一些变通方法.

This is actually a little tricky, but you have a few options. The main problem is that you need to send the SMS messages from the Twilio number to the consultant, but that may contain multiple conversations. Twilio will keep the session/cookies etc, but only unique to two numbers. As SMS doesn't have anything that allows you to add any extra metadata, so you need to look at a few work-arounds.

这里的主要问题实际上是 UX - 如果顾问收到来自客户实际号码的 SMS 并通过 SMS 回复,则 SMS 将发送给客户,而不是 Twilio.此时,顾问泄露"了他们的直接手机号码.

The main problem here is really UX - if the consultant receives the SMS from the customer's actual number and replies by SMS, the SMS will go to the customer, not Twilio. At this point, the consultant 'leaked' their direct mobile number.

让我们通过一个客户的消息流:

Let's go through a message flow with a single customer:

客户向 Twilio 代理号码发送短信:

The customer sends an SMS to the Twilio proxy number:

Customer -> Twilio Number -> Consultant

然后顾问回复 Twilio 号码,并转发到:

Then the consultant replies to the Twilio Number, and it is forwarded on:

Consultant -> Twilio Number -> Customer

这很好.可以通过 Twilio 号码在顾问电话上进行对话.当顾问回复时,您的应用只是充当代理,将消息转发给客户.

This is fine. The conversation can be threaded on the consultants phone by the Twilio number. When the consultant replies, your app simply acts as a proxy, and forward the message to the customer.

当您添加第二个客户时,顾问真的很难知道消息来自谁.因为从顾问的角度来看,它们都来自相同的 Twilio Number!

When you add a second customer, it's really hard for the consultant to know who the message is from. Because they both come from the same Twilio Number from the consultant's perspective!

Customer1 -> Twilio Number -> Consultant
Customer2 -> Twilio Number -> Consultant

然后回复:

Consultant -> Twilio Number -> ??

当顾问回复时,您将消息发送给哪个客户?他在回应哪个对话?有几个选项:

When the consultant replies, which customer do you send the message to? And which conversation is he responding to? There are a couple of options:

1 多个号码

为客户使用单个号码给顾问发送短信,但在向客户发送短信时使用多个不同的号码作为发件人号码.所以客户只有一个号码,但顾问有很多不同的号码,每个客户一个.如果顾问有数百个客户,即使每个月 1 美元,这可能会有点贵!

Use a single number for the customer to SMS the consultant, but multiple different numbers as the from number when sending on the customer. So the customers only ever have one number, but the consultant has many different ones, one for each customer. This could get a little pricey if the consultant has hundreds of clients, even at $1 month/each!

2 个密码

在每个 SMS 前面加上一个识别客户端的密码.所以 <消息>.然后,当顾问回复时,他们会指定他们正在回复的对话的 .不过,这并不是最好的用户体验,而且会使跟踪消息线程变得有点棘手.

Prefix each SMS with a pin number that identifies the client. So <ID> <Message>. Then when the consultant responds, they specify the <ID> of the conversation they are replying to. It's not the best user experience though, and would make following a message thread a little tricky.

3 个应用

这是我最喜欢的解决方案,但需要做更多的工作.为他们构建一个 Web 或移动本机应用程序,使用推送通知在设备和 Twilio 之间加入.这允许您在原始发件人/收件人号码上无缝地串接对话,而不必添加额外的数据来代理对话.它还允许顾问保存客户的号码,因为他可能会收到一张带有手机号码的名片,并且 SMS 消息可能假定他已将该号码添加到他的手机中.这也意味着他可以从任何地方访问这些 SMS 消息,他不再绑定到自己的手机!它可以在平板电脑/笔记本电脑/台式机/任何设备上运行!

This is my favourite solution, but requires a little more work. Build a web or mobile native app for them that uses push notifications to join between the device and Twilio. This allows you to thread the conversations seamlessly on the original From/To number, rather than having to add extra data to proxy the conversation. It also allows the consultant to save the numbers of customers, as he may be given a business card with a mobile number on it, and the SMS message may assume he's added that number to his phone. It also means he could potentially access these SMS messages from anywhere, he's no longer tied to his own phone! It could work on a tablet/laptop/desktop/whatever!

这是一个相当棘手的问题,因为 SMS 是无状态的.Twilio 确实保留了状态,但这仅对每对数字唯一,一对(来自/到)不能有多个会话状态.

This is quite a tricky problem to work with, simply because SMS is stateless. Twilio does preserve state, but that is only unique to each pair of numbers, a single pair (from/to) cannot have multiple session states.

我希望这会有所帮助!

这篇关于Twilio 作为一对多 SMS 对话的代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆