Twilio - 如何识别用户何时使用退出关键字回复并取消订阅? - 姜戈 Python

Twilio - How to identify when user replies with opt-out keyword and unsubscribe them? - Django Python

当用户使用 twilio 的默认退出关键字之一回复时,我想取消订阅用户的短信通知:STOP、UNSTOP、UNSUBSCRIBE 或 CANCEL https://support.twilio.com/hc/en-us/articles/223134027-Twilio-support-for-opt-out-keywords-SMS-STOP-filtering-

如果客户端键入“开始”、“是”和“取消停止”,则重新订阅我的数据库和短信通知

有什么特殊的方法吗? - 我没有从 Twilio 看到任何关于如何处理这个问题的好文档。或者我是否只需要观察用户通过我现有的短信 webhook 进行回复并实现如下内容:

def text_message(request):
    if request.method == "POST":
        message_body = request.POST['Body']
        if message_body == "STOP" or message_body == "UNSTOP" or message_body == "UNSUBSCRIBE" or message_body == "CANCEL":
            #unsubscribe phone number from my database

您是对的,您的应用程序需要合并逻辑来更新您的 CRM 中的用户频道首选项(这样,如果该用户选择退出该频道,您就不会尝试发送另一条 SMS)。 Twilio 处理长代码的黑名单,因此如果您尝试向选择退出方发送 SMS,Twilio 将响应错误。

Twilio 支持选择退出关键字(SMS STOP 过滤) https://support.twilio.com/hc/en-us/articles/223134027-Twilio-support-for-opt-out-keywords-SMS-STOP-filtering-

Any of these STOP keyword replies will prevent a customer from receiving new messages from the Twilio phone number they're responding to. When Twilio receives one of these replies, we will create a "blacklist" entry on our side, and then pass the message on to your webhook. Once we have a blacklist entry for a particular recipient phone number, any future attempts to message them will be met with a 400 response from our API, along with Error Code 21610 - Message cannot be sent to the 'To' number because the customer has replied with STOP. Recipients can disable this message stop, and resume receiving messages with the START, YES, or UNSTOP commands as outlined below.