Proper structure - Twilio Callback - twilio

I have been having some success sending sms messages with Twilio via curl. Now I am wanting to implement the callback url to track the status of the message.. I cannot seem to get the call back to work
I have tried encoding it in JSON and also appending it as parameter and I havent been able to have any success.. Any help is appreciated

It's not JSON, it is sent as urlencoded (application/x-www-form-urlencoded).
Where do I find the specifications for inbound HTTP requests to my server?

Related

Twilio API get DateSent from StatusCallback URL?

I am using Twilio and I want to get the DateSent parameter of a message. When the message is initially sent it has null values for both DateCreated and DateSent. So I pass a StatusCallback URL to receive any status updates on that message. However, I am able to get only the new statuses the message gets such as sent, or delivered and not the new date as an event. In the docs I couldn't find anything about this either (https://www.twilio.com/docs/sms/send-messages#monitor-the-status-of-your-message). What is the way to get this information without continuously polling the API?
The date created is included as part of the response from the API. If you find that is not the case can you please post example code.
When the sms is actually sent you can pull the message resource using the api or sdk via the sid https://www.twilio.com/docs/sms/api/message-resource#fetch-a-message-resource

Twilio Application Error making Calls

Trying to make call from my app to a number using Twilio API's
When call is received, getting application error
and here is the debugger logs for that call:
Error - 11200 HTTP retrieval failure 502 Bad Gateway errors
Passing a URL when POST Request.
Can anybody help me through this?
have you taken a look at this information from Twilio? They give possible causes and possible solutions for the error you received. Did you specify the correct content-type header in your response?
If you could share your code, that would be great!
Hope this helps!

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

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

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

Twilio is sending the Message Fall Back URL text along with actual text

Initially I have been using the TwiML response to send response to my text messages. But since my requirement has changed and I need to send more than 10 messages in response to my text hence I am now using the Twilio API to send the message out. So to fix this now I am trying to send nothing as the TwiML response for my Text Messages and instead using the Twilio API to send the actual messages out. I also have a TwiML bin URL attached to my short code as a Message Fall Back URL in case Twilio is not able to connect to my REST API URL. So now when a Text message is received by Twilio it connects to my REST API and the response is sent. But I am getting the response from the Message FallBack URL first and then the actual response for my text message via the Twilio API. Is there anyway to avoid this? I can remove the Message Fall back URL but then what would happen in the actual case when Twilio is not able to connect to my server?
This is how I have added the code:
var twilioResponse = new Twilio.TwiML.TwilioResponse();
...... have code that uses Twilio API to send out more than 10 messages.
...... Since the messages are going out via Twilio API hence returning NULL to the TwiML response
return Request.CreateResponse(HttpStatusCode.OK, twilioResponse.Element);
More Updates:
As I mentioned earlier I'm using the REST API to send an SMS. When a Text request comes Twilio server calls my URL supplied to the REST call.
Sometimes my server is little slow in responding - in which case twilio gets the fallback URL message and passes on the text message.
How do I increase the timeout ? This timeout is the time the server responding with TWIML.
Please help - any pointers are appreciated.
Twilio evangelist here.
My first suggestion would be to check your accounts App Monitor to see if Twilio is logging any errors. The Fallback URL should not be getting requested unless Twilio fails to get a valid response from the primary URL.
The default timeout for a Twilio request is 15 seconds, so if your server is taking longer than that to respond there may be a bigger issue happening with your server or network.
Hope that helps.

Resources