Twilio Studio to automatically add contacts to segments?

Suppose you want to add a contact to a segment if you receive an SMS from them. For example, you have a radio ad, or a mail add that says “Text me “signup” to receive weekly alerts.”

Well, that’s fine if they are already a contact in Mautic, but using that kind of campaign, they probably won’t be.

Why can’t we use a webhook from Twilio (using Twilio Studio; more below) to send a webhook to our Mautic instance with a Tag to add (call it alerts-signup). Once they are tagged, they can be added to a segment based on that Tag, and start receiveing SMS from us. We can even automatically ask for their email address and push that to Mautic, too (again using Twilio Studio).

Twilio Studio is a free (well, included if you use Twilio) mostly-code-less method of creating marketing automation apps. It can do a lot of things, including sending variable webhooks based on incoming SMS. Look at the crude illustration, below.

I used Twilio Studio to assemble the payload, what I do not know how to do is configure Mautic to receive the Payload.

The URL-Encoded payload is below (this can easily be changed if needed). What is below is how the content of the webhook comes from Twilio, by default, with the exception of I added the “MauticTag” of “ALERTS-OPT-IN”. You can also just as easily configure a JSON payload.

AccountSid:
ACCOUNTSID
ApiVersion:
2010-04-01
Body:
THIS IS THE BODY
From:
+1551112222
FromCity:
CITYNAME
FromState:
STATENAME
FromZip:
ZIPCODE
MessageSid:
ANSMSID
SmsMessageSid:
ANSMSID
SmsSid:
ANSMSID
To:
+15552223333
MauticTag: 
ALERTS-OPT-IN

I would be happy to do a write-up of how to do the Twilio Studio side, but I would need help with is how to “catch” the Payload on the Mautic side.

@joeyk
@rcheesley