Uptill now I have been using Twilio for phone calls. Now I want to be able to have a network monitoring tool that texts when there is a problem to a number. I would like to make it so that when twilio receives the text it will execute the script that I have put into its URL...I really don't know how to get started with sms it seems very hard and complicated as compared to phone calls...Any help on the sms is greatly appreciated to get me started.
If you've already figured Twilio voice calls, you'll find SMS easier once you figure out what they're doing. Which is essentially:
Carrier delivers an SMS to Twilio for a number you're renting from them.
Twilio makes an HTTP POST or GET (you choose) to the URL you setup in their web admin. The content of the text message will be a parameter in there.
You do whatever you want with the POST or GET, returning a TwiML if you want an SMS reply sent or nothing if not.
Note, Twilio can't execute a script for you, unless it's TwiML, in which case you're just returning TwiML as the response to the HTTP call from #3. So if you want to do something in response to an SMS, you'll need build that something into the logic that handles the URL you've given Twilio. If you're still lost a bit, tell us about how you're trying to do this, e.g., you've a Rails app, a PHP website, or just a Bash script you want to run and nothing else yet...
Why not avoid Twilio and have your network monitoring tool execute the script itself?
Related
As subject says I am reading api docs for twilio but even after brainstorming for 2 hours I am still unable to figure out exactly how can I receive a call from twilio on my web application and answer the call with my own voice like we do in a real phone.
I know how to respond a call when someone call your twilio number but that's only text to speech conversion like their "Hello Monkey" example application but nothing so far about answering a call using their API.
Can anyone please explain how can we do that? Not everything, just main concept and few references if possible
I am using Laravel so would be good if it's in php
Twilio evangelist here.
I would suggest working through the Twilio Client for JavaScript Quickstart. This will walk you through both the server and client side code needed to build a phone in your browser, showing you how to both make outbound calls from the browser to a PSTN phone as well as receive incoming PSTN calls in the browser.
The magic that you are looking for in either of those cases is the <Dial> verb. When an incoming PSTN call comes into Twilio, you can use the Dial verb to tell Twilio to dial and bridge that call with a Client instance:
<Dial>
<Client>jenny</Client>
</Dial>
When and instance of client make an outbound call and wants to connect to a PSTN phone number you again us the Dial verb:
<Dial>
<Number>+15555555555</Number>
</Dial>
The quickstart shows in more detail how this works.
Hope that helps.
You tried the Twilio PHP lib? As for Laravel... Incoming call? No problem!
Please try to use Google before asking questions! I think one important trait to any programmer is the ability to organize the idea of "what you want", and then google each step to get it that you want...
What I am trying to accomplish is quite simple. I want to store all received SMS messages from a Twilio number in a database. Upon checking Twilio's documentation, their TwiML word should be able to do this, but no attribute relates to this:
https://www.twilio.com/docs/api/twiml/sms
Twilio developer evangelist here.
When your Twilio number gets sent an SMS, your application receives a webhook at the URL you supply in the settings for the number. For each messages, the webhook sends a number of parameters telling you about the message. The documentation for that can be found here: https://www.twilio.com/docs/api/twiml/sms/twilio_request.
You might want to take a look at our PHP Quickstart tutorial which will give you a good idea of how to get the details from the request. You will then just have to pick which attributes you want to store in your database.
Let me know if this helps.
I have created a free account in twilio for sending SMS through my website. After my registration I got a twilio number like XXX-XXX-XXXX. I am able to send message to mobile numbers but I don't know how to use this twilio number for receiving SMS. Please help me out on this.
Twilio evangelist here.
The way Twilio notifies you of both incoming SMS message and incoming voice phone calls is by using something called a webhook. This is basically an HTTP request that Twilio makes to a URL that you tell us about. Normally this URL is a web app that you've created and published to a public website.
http://en.wikipedia.org/wiki/Webhook
In your Twilio dashboard, click on the Numbers tab and you will see your trial number.
https://www.twilio.com/user/account/phone-numbers/incoming
Click the phone number and you will see two input fields, one for a Voice URL and one for a SMS url. Just put your URL's there and click the save button.
Now if you send a text message to your number, Twilio will make an HTTP request to the URL you've told us about. You can think of this like a standard Form submit. Twilio will send along parameters like the number the SMS is coming from and the body of the message. The full list of parameters we send to the SMS url is here:
https://www.twilio.com/docs/api/twiml/sms/twilio_request
Your app can grab those parameters and use them however it wants. Your app can also return TwiML instructions to us that tell us to respond to the SMS.
https://www.twilio.com/docs/api/twiml/sms/your_response
You might want to check out our quickstarts for examples of how to receive a text message and and howtos for lots more examples of both sending and receiving SMS messages.
https://www.twilio.com/docs/quickstart/php/sms/hello-monkey
https://www.twilio.com/docs/howto
Hope that helps.
Devin
Has anyone found a way to use google voice to send a phone call without first calling you. I need a phone to ring, but it is not necessary that any particular message be sent or anything. Here is the API I've been looking at. https://github.com/aaronpk/Google-Voice-PHP-API In the API you specify your google voice number and the recipient's number, and then it calls your phone and connects you to the recipient. I'm looking for a way to just connect to the recipient.
That's just the way Google Voice works... to call out you either a) use the web interface, which calls one of your phones then dials the other person or b) you call you own GV number and use the menu to dial out. The API packages I've looked at all use the GV mobile site to dial or send text messages (method a).
The only method I can think of for your scenario would be to get a free VoIP account with a number somewhere and set up a softphone that auto-answers.
But that begs the question... what is your purpose...? web driven prank calls?
I was using this for a system to alert people when a computer system I created needed attention. Text alerts are good...unless you're asleep and can't hear them. So, what I did was create a google voice number and then delete all of the phones off of it, and record a long voicemail. This way, it calls, and goes straight to a message that tells them the system needs attention and then they can just hang up and respond.
Slight work around, but it seems to work out fine.
I want to add an additional functionality to a CMS I am making that will allow users to add content to a site via text message. The user should be able to upload an image and add text and send the message to a number which when received will update the database accordingly.
Can this be done, and can it be done via PHP because that's the only language I know? Also what would be the general outline to achieve such a thing?
You have to find a SMS gateway that supports "incoming" of SMS. Click-a-tell is generally the one people choose because of their API and documentation, they aren't free though. If you do a quick Google search for "SMS Gateway" you'll find plenty of other solutions.
Once you choose the gateway you want to go with, the rest of the process is easy. You would just handle the SMS as a regular request into your application.
Hope that helps you get started!
Use one of the many SMS gateways out there like Twilio (whom I work for, but loved before I was an employee) which has a really simple API and great documentation. There are tons of PHP examples. When you receive a message, a simple POST request is made to a URL you specify with parameters for To, From and Body. Also if you return text from the URLs you use to receive messages you can respond back to them. You can also initiate outbound SMS from the same number using the REST API.
Twilio does not currently support MMS (needed for your image uploading requirement) and is not free, but you only pay for what you use at $.01 per message.
Completing the answer by Raphael Caixeta, I recommend that you use the standalone PHP binary to run a pre-determined script, which parameters you'll get from the SMS/MMS. This way you can separate the two process:
1) Make a script and test it by running it through the command line.
2) Implement the SMS/MMS receiver software so that it parses the messages and runs the first script with custom parameters.
You can use a GSM/3G modem (or dongle) to receive SMS messages. And this sms software can read those messages from the modem in real time and put them automatically in your database.