Twilio - Send message to multiple recipients

I am trying to send Twilio text messages to multiple recipients but am having issues getting it to work properly. I’ve searched documentation but haven’t found many examples of Twilio in docs. I would like to create a table that would allow people to create a send messages to a group of people depending on the people referenced from another table. When I tried doing a formula map, it did not work. I read that Twilio has to run separate GET requests so perhaps formula map isn’t compatible.

I have sent group messages but adding a Twilio button to each row that a person is on, but easily adding customs messages and making it intuitive for the users who would send the messages has me a little stumped. Does anyone have experience with this? I made a dummy doc to kind of show what I am trying to do.

Group Twilio Messages

Thanks!

I’ve edited your doc so that it does what you want. It’s possible but ugly.

Essentially, I added a column that brings in the students you wanted to send a text to:
image
All it does is look up the people that have the group tag that you want. The formula used here enables you to use multiple different tags per person if you want.
People.Filter(thisRow.Group.Contains(Tags))

Then your (purple) send sms button just goes through the list of people that will get a text and presses the “send SMS” button for each of them.
thisRow.[Who will get text?].FormulaMap(RunActions(CurrentValue.[Send SMS]))
But, before it can do that it needs to indicate that this is the message to send, which it does by changing the “Send This Message” column to a 1. That means that it needs to change all the columns back to 0 afterward.

Set “Send This Message” Column to 1
ModifyRows(thisRow, thisRow.[Send This Message], 1)
Set all “Send This Message” Columns back to 0
ModifyRows(thisTable, thisTable.[Send This Message], 0)

So combining this with the previous message that actually presses the buttons in the People Table, it looks like this mess:

RunActions(
    ModifyRows(thisRow, thisRow.[Send This Message], 1),
    thisRow.[Who will get text?].FormulaMap(
        RunActions(CurrentValue.[Send SMS])), 
    ModifyRows(thisTable, thisTable.[Send This Message], 0)
)

This means that your (blue) Send SMS button in the People table needs to look up which message to send from the Messages table. It does so with Messages.Filter([Send This Message]=1).[Message + Signature]) because it’s trying to find the Message + Signature associated with the row that has Send This Message selected.

Finally, to show you that it’s doing what you expect, I’ve told it to open up a web page that will display the text it’s intending to send. That’s why it takes you to large-type.com/#large-type.com%20is%20a%20website%20to%20easily%20display%20text%20from%20urls

OpenWindow(Concatenate("https://large-type.com/#", Format("Simulate send message to {1} {2}",thisRow.Student, Messages.Filter([Send This Message]=1).[Message + Signature]).EncodeForUrl()))

However, this is not the right way to do this

Instead, you should use a FormulaMap of the users and run a single Twilio action (as I’ve simulated with a button in The Right Way Twilio Page with the Send Message to button) You could put my button into your table, it should work.

The thing to keep in mind is that you can run a formula like People.Filter(something=true).FormulaMap(TwilioAction(CurrentValue.Number, CurrentValue.Name) ) I know that’s not the exact signature of the Twilio Action but it should get you on your way.

1 Like

Thanks so much @Connor_McCormick. I implemented your revised version and it worked. I originally had it fail saying I violated a blacklist rule when testing with a friend that was in the room with me, but I tried with another number and I was able to send multiple texts via the button. So I think that was probably just a Twilio setup.

1 Like