英文:
Sending drip SMS via Twilio in a flow
问题
这是我的第一篇帖子;我是一个非开发者,正在努力学习如何使用Twilio。
我已经掌握了Twilio Studio的基础知识,包括有限的API,但无法弄清楚如何完成以下任务,如果可以得到一些帮助,那将非常感谢。
不确定是否重要,但这只是一个概念验证;我最近做了手术,一个月后他们给我发了一封电子邮件调查,问我几周前的感觉,我觉得这是毫无意义的。现在,作为一种学习方法,我正在尝试弄清楚通过短信是否可以实现更好的客户体验,以及如何实现。
患者会在不同时间段收到文本消息(手术当晚,然后术后7、14和21天),要求他们回复一个从1到10的数字来评价他们的疼痛程度。
我的尝试...
到目前为止,我已经成功构建了第一条消息,其中患者的手术日期、名字和手机号码被存储在Google Sheets中。一个Webhook被发送到Twilio Studio,在手术当晚的6点发送一条消息,由Pabbly提供支持。
我知道Twilio没有原生的延迟功能,但我偶然发现了下面的代码,但我不确定是否可以延长到1周,如果可能的话,是否有更好的方法来实现?
exports.handler = function(context, event, callback) {
setTimeout(function() {
callback();
}, 2000);
};
我真的不想等着去找出来,我记得在某个地方读到关于这个延迟功能的限制。我一直在研究这个准确的代码,以实现快速暂停回复,以减少过于快速回复的自动化感(从Twilio的使用案例示例中学到的)。
解决方案确实需要遵循一种流程,这样就不会出现疼痛评分与错误的时间段相关联的风险。它还需要从相同的号码发送,所以多个API调用不起作用(据我所知),关键字也不会起作用,因为患者的回复不是唯一的。
谢谢,Brendan
英文:
This is my first post; I'm a non-developer trying hard to learn how to use Twilio.
I've got my head around the basics of Twilio Studio including the limited API but can't figure out how to accomplish the following if I could get some help, please.
Not sure if it matters but this is just a POC; I recently had surgery and they sent me an email survey after a month asking me how I felt weeks ago which I thought was pretty pointless. Now, as a learning method, I'm trying to figure out if and how this could work via SMS for a better customer experience.
The patient is sent a text message at intervals (the night of surgery, then 7, 14 and 21 days after) asking them to rate their pain by responding with a number from 1 to 10.
My attempt...
So far I've managed to build the first message, where the patient's surgery date, first name and cell phone number are stored in Google Sheets. A webhook is sent to Twilio Studio to send a message at 6pm on the night of the surgery, courtesy of Pabbly.
I'm aware that Twilio doesn't have a native delay feature, but I stumbled upon the code below, but I'm not sure if this could be extended to 1 week, and if even possible, if there's a better way to achieve this?
exports.handler = function(context, event, callback) {
setTimeout(function() {
callback();
}, 2000);
};
I don't really want to wait to find out and think I read somewhere about limits on this delay feature. I've been working on this exact code for a quick pause on replies to reduce the automated feel of ridiculously fast replies (learned from a Twilio use case example).
The solution really needs to follow a flow, so it doesn't risk having pain rates associated with the wrong time period. It also needs to be sent from the same number, so multiple API calls won't work (as far as I know), nor will keywords, since patient responses are not unique.
Thanks, Brendan
答案1
得分: 1
似乎您对发送预定消息和在特定间隔内感兴趣。您可以尝试一个名为“消息调度”的功能。
以下是一个示例:
client.messages
.create({
messagingServiceSid: 'MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
body: 'This is a scheduled message',
sendAt: new Date(Date.UTC(2021, 10, 30, 20, 36, 27)),
scheduleType: 'fixed',
to: '+15558675310'
})
.then(message => console.log(message.sid));
使用消息调度,您可以安排在15分钟以上、7天以下的时间内发送消息。
基本上,您需要添加一个带有您想要发送消息的时间的 sendAt
参数。您可以执行日期时间操作,以便在手术后的7天内安排消息(将7天添加到手术时间)。
由于您正在使用Twilio Studio,我建议阅读我写的关于如何在Studio中安排消息的博客文章。虽然是用Python编写的,但同样的原则也适用于其他编程语言。
英文:
It seems like you're interested in sending out scheduled messages and at certain intervals. You could try out a feature called Message Scheduling.
Here's an example:
client.messages
.create({
messagingServiceSid: 'MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
body: 'This is a scheduled message',
sendAt: new Date(Date.UTC(2021, 10, 30, 20, 36, 27)),
scheduleType: 'fixed',
to: '+15558675310'
})
.then(message => console.log(message.sid));
With Message Scheduling, you can schedule a message more than 15 minutes ahead to fewer than 7 days in advance.
Basically you add a sendAt
parameter with a time that you want to send a message. You can perform datetime operations so you can schedule a message 7 days after their surgery (by adding 7 days to the time of their surgery).
Since you're using Twilio Studio, I'd recommend reading this blog post I wrote about How to Schedule a Message in Studio. It's written in Python but the same principle applies to other languages.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论