Using Twilio to respond to an SMS with a http redirect to an external webapp - twilio

so, when i send a text message to twilio number, i want it to trigger a specific event in the webapp via http POST. For example, by making a http call to the webapp URL (http://webapp.com/triggerA) which it process to trigger an event A in the webapp.
Can I do this with twilio? If,so is there a sample piece of code which I can refer.

From what I understand from your question, I think you can do the following.
With Twilio, when you login into here
https://www.twilio.com/user/account/phone-numbers/incoming
You will find a list of your incoming numbers, I am assuming that you have already purchased a number. Once you click on a number in the list, you will find a page that where you can view and set various properties for the number you are looking at.
You will see a header called Messaging. Under that menu you will see a request Url.
you can set this to http://webapp.com/triggera as per your example. you can also choose whether you would like to use a http post or a http get request type.
the link below, will help you further for handling the data that Twilio passes your application.
https://www.twilio.com/docs/api/twiml/sms/twilio_request
Louis

Related

Twilio Advanced Opt-in not sending

I'm building a text service with Twilio and configured and enabled the Advanced Opt-out / Opt-in settings in my messaging service.
When testing the opt-in with my custom keyword I get this back instead my custom message
Thanks for the message. Configure your number's SMS URL to change this message. Reply HELP for help . Reply STOP to unsubscribe. Msg&Data rates may apply.
The screenshot shows my custom keyword and message. I'm using a toll-free number.
Any ideas as to why its not automatically sending the custom opt-in message?
When you receive opt-in messages to your number the webhook request is still sent to the URL you configure for your number. It looks like you haven't configured that URL for your number yet, as that is the default response for a new number.
Head to the Twilio console to configure your number and update the URL for when a message comes in. You can set it to your own application's URL if you have built that out yet, or if you are still working on that you could use a TwiMLBin with an empty <Response> which doesn't respond if you don't have an application yet.

How do I call a number with Twilio Studio flow REST API execution

The purpose is simply to call a number (my number) and have a message start playing.
I have created a Studio Flow like so:
And published that flow.
I've also bought a phone number and it is activated for voice & messaging. I can receive a test voice call with code and using TwiML).
In the settings of my phone number I have the following:
Accept: Voice Calls
Configure with: .. Studio ..
A call comes in: Studio Flow (and selected the correct flow)
I then proceed to use Postman to try and trigger my Flow using a POST request with the following parameters:
And the following body parameters where the To number is my number which is verified in my trial account, and the from is the number i purchased in twilio:
After clicking on Send in postman I receive a 200 OK message, but I am not receiving a call on my phone. What step am I missing?
Twilio developer evangelist here.
The variable you are using as the number to dial out from Studio is {{contact.channel.address}} but the contact variable refers to "data about the current contact engaging with your flow, such as their phone number".
Since you have triggered the flow with a REST API call there is not a contact that is currently engaging with the flow, so this won't give you the number you want.
You are, however, sending in some parameters from your HTTP request from Postman, notably a To parameter. Your data that you send to the flow endpoint like this will be available under the trigger context variable.
So, you should update your widget to use {{trigger.To}} instead (and you probably don't need From, as that is the number associated with the flow, or Body).
Let me know how you get on with that.

How to Forward SMS Message to URL

I used this as my helpguide: Twilio: Forward received SMS to URL
But the problem is I cannot extract anything from the set of parameters.
I'm using Classic ASP and I'm try to capture anything that exists in the Request.QueryString by placing it into a database.
All I want to do is to insert the from phone number and body/text message into my database every time a message is received. All I get is an empty record in the database.
By default when Twilio receives an SMS to your Twilio phone number it makes a POST request to your ASP page, sending a set of form-encoded values. This means you should use:
Request.Form("Body")
If you want Twilio to make a GET request instead, allowing you to use Request.Querystring, you can configure that on the phone number configuration page in your Twilio Console.
According to the docs, the default value for Twilio's StatusCallbackMethod is POST, so unless you've specified otherwise, you will be receiving your desired parameters in the POST body, not in the query string.
If you just want to forward an SMS to a URL or Rest API there are few android apps that do just that, most of them are paid ones.
This is one example:
https://www.forward-sms-to-rest-api.com

Twilio: Dial extension number along with twilio number

I am using Twilio for inbound calls, where user can call an application through Twilio-Number (brought from Twilio) and will be redirected to admin.
Now, We want Admin to call User using same Twilio-Number. We wabt to call this as <Twilio_Number>#<user_id>. We want to pass <user_id> as extension, so that when Admin clicks on the link with tel=<Twilio_Number>#<user_id>, it will initiate a phone-call to twilio-number.
In our app, we will find user's mobile using his id and redirect call to user's mobile number.
I have referred this doc: https://www.twilio.com/docs/howto/companydirectory
But would need few more details like:
How will Twilio recognize the extension number? And by which name is it provided in call-request parameters?
Currently, we received these parameters in twilio-voice call request
CallSid, AccountSid, ApiVersion, Direction, To, Called, Caller, From. In the same request-parameters, how I can get extension digits?
Thanks.
Have you had the chance to review the IVR information provided on Twilio's site? I believe it is a better solution for what you are trying to accomplish.
https://www.twilio.com/docs/howto/ivrs-the-basics
(Please follow the links to the next section at the bottom of the pages.)
After reviewing the documents, please open a support request with specific questions via https://www.twilio.com/user/account/support/ticket/create
Look forward to your ticket.
Take care!
I don't know if you solved this problem yet (probably yes) but what you can do is, create a record in DB with the extension (id agent) and when Twilio go to your callback url updated the records depending of the state.
Hope this works to you. I'm doing this with the same scenario.

How to detect url attribute action was complete and connected between users in twilio?

I set url attribute for number and client verb for some scripts. I had some delay to execute that scripts so I want to detect when connect between users after the scripts. is it possible ?
There are a couple of ways that Twilio can tell your application the status of a call.
Set the Voice Request URL to get updates during the call (and respond with additional TwiML).
Set the Status Callback URL to get the results at the end of the call.
This page will explain this in detail: https://www.twilio.com/docs/api/twiml/twilio_request

Resources