Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
357 views
in Technique[技术] by (71.8m points)

Can I use twilio studio flow with ultimate sms on same phone #?

I'm new to twilio. I have the "ultimate sms" plugin from codecanyon set up on my domain and connected to a twilio #. Is there a way to use the same # to set up a studio flow? I'd like to have people be able to send a text like "join" to my current twilio # and I can add them to a distribution list. As far as I can tell, I seem to only be able to set up 1 kind of messaging configuration for incoming messages. If possible, I'd like to use the same # for both workflows. Thank you!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Twilio developer evangelist here.

Twilio numbers process incoming messages by sending a webhook (HTTP request) to a URL. I have not used "Ultimate SMS", but I would assume the plugin requires you to set the Twilio webhook to your application so that it can manage the incoming requests.

Twilio Studio flows like to control the entire conversation, so is probably not a good idea for dealing with this.

You might be able to put some code between the incoming message and the webhook to do things based on whether the body starts with "join". Using a Twilio Function, you could write something like this:

exports.handler = async (context, event, callback) => {
  if (event.Body.startsWith("join") {
    // Subscribe the user to your list
    const response = new Twilio.twiml.MessagingResponse()
    response.message("You have subscribed to the list");
    callback(null, response);
  } else {
    // Send the parameters on to the Ultimate SMS webhook URL and respond with the received response
    const response = await getResponseFromWebhook(event)
    callback(null, response.body);
  }
}

This code is just a rough example, but hopefully you get the idea. You can proxy the webhook request through a Function like this (or an API endpoint written in any language if you don't want to use JavaScript or Twilio Functions) and peel off messages you want to by inspecting the body.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...