I am using twilio right now by writing a python script and hosting that with ngrok. When I visit the webpage hosted and view the source, I just see TwiML. Is it possible to just write TwiML w/o code?
Twilio employee here.
Of course you can! If you want to, you can just link the URL to an xml file that you've written and stored on your server - no programmatic generation of the TwiML is required.
One of the simplest ways is to write some plain TwiML on TwiMLbin and just link to the public url for it.
Twilio is just looking for an XML string response to the request it sends - it doesn't care or understand how you generate it.
Related
I have some issues trying to pass a custom parameter to TwiML Bin. See attached pictures.
Everything works except the paramter.
Any ideas of what I am doing wrong?
Setup:
Twilio developer evangelist here.
ApplicationSID is from TwiML applications which are containers for a set of URLs and configurations that tell Twilio what to do when one of your Twilio numbers receives a call or SMS message.
If you're using dynamic content from custom HTTP request parameters (ie. name in this case), you should take your TwiML bin's URL and pass it the Name parameter like this in, for example, Python, to generate a call with the custom parameters:
client.calls.create(
url="your-twiml-bin-url?Name=Jeremy",
to="your-phone-number",
from_="your-twilio-phone-number")
When i make a call as voice content to that call, can i send a dynamically generated twiml message rather pointing to a URI that contains twiml message ?
If not is there a a workaround to accomplish this , cause I see DIAL and SAY APIs which get used during call response, so would it be possible to make use of those when creating a new call and passing twiml messages using these APIs ?
https://www.twilio.com/docs/api/twiml/dial
https://www.twilio.com/docs/api/twiml/say
Twilio evangelist here.
Its not possible to send TwiML to the REST API. If you don't want to host the TwiML on your own URL there are a few options:
Use TwiML Bins which lets you host relatively static (there is some templating support) TwiML on Twilios servers.
Use Twilio Functions which let you write, store and execute Node on Twilios servers
Use Twilio Studio to define your call flow. A flow in studio can be triggered via an HTTP request to it, so you can take the flows URL and pass it to the REST API when you start your outbound call.
Hope that helps.
We have implemented an IVR system which also redirects calls to a Call Center. The Call Center wants us to send relevant information in the custom SIP Header so that the IVR can pass custom information that will be useful to service the call without requesting the information entered in the IVR again.
I have tried to find documentation which clearly explains what is needed to be done but have had no luck.
Is it as simple a adding custom headers as SipHeader_X-headername=headervalue as part of the Voice response as mentioned in https://www.twilio.com/docs/api/twilio-sip/sip-twiml
or something else is required like the SIP URL as mentioned in https://www.twilio.com/docs/api/twiml/sip
Any direction/help will be really helpful.Thanks in advance.
UPDATE to question :
Configured an URL in Twilio to direct calls.Using Java based Microservice app using Spring Boot to service the URL calls. The below code snippet contains the Dial to the CSR.
String say = null;
Redirect redirect;
VoiceResponse.Builder builder = new VoiceResponse.Builder();
say = messageSource.getMessage("You are connecting to CSR", null,
Locale.ENGLISH);
builder.say(new
Say.Builder(say).voice(Voice.ALICE).language(Language.EN_US).build()).dial(new
Dial.Builder().number(new Number.Builder(number).build()).build());
response.setContentType("application/xml");
response.getWriter().append(builder.build().toXml());
Sounds to me like you are dialing out to a SIP endpoint so your extra parameters should look something like this from the docs you linked to:
$dial->sip('sip:jack#example.com?mycustomheader=foo&myotherheader=bar');
I'm a very new programmer and am messing around with creating URL's to send SMS or MMS messages via Twilio (my application is for home automation where if my camera detects motions, I want to send a still image to an MMS number via a URL).
Can someone post the format for sample URL for an MMS message that I can paste in a browser?
For example, if I have a To parameter of To=+7145551212 and a From parameter of From=+7145551111 and MediaURL=http://test.com/image.jpg, what would the format of the URL need to be?
I have my Account SID and AuthToken as well. Just need an example of what a completed URL would look like so I can work backwards from there.
Thanks!
Paul
If I'm understanding you correctly, I think it would be this :
https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages
And then your parameters need to be in the POST body of the request, like
To=+7145551212&From=+7145551&MediaURL=http://test.com/image.jpg
But Brodan's comment is correct- you can't do this through just pasting a URL into your browser, because it's a POST request. You could use cURL, something like this :
curl --data "To=+7145551212&From=+7145551&MediaURL=http://test.com/image.jpg" https://api.twilio.com/2010-04-01/Accounts/123456/Messages
But your best option would really be to use one of the Twilio helper libraries. Here's a link to their description of the endpoint, they have examples of using those libraries in a variety of languages.
Note : I have never used Twilio myself.
Tropo has a scripting engine using which we can write code in scripting language for voice and sms applications. e.g. the python code to answer a call looks like,
answer()
say("thanks for calling")
transfer("tel:+1xxxxxxxxxx")
hangup()
Is there something similar available for Twilio. I see that they have Python wrapper over their SDK using which one can do something similar. But I need to find out if there is something similar that Twilio has.
Thanks,
gg
If you need to do anything dynamic (respond in different ways based on who is calling), you'll need to provide Twilio with a URL, and then respond with TwiML at that URL.
You can create TwiML with Python with the helper library: Creating TwiML with twilio-python
If you are responding to every call in the same way (eg a static reply), Twilio has Twimlets you can use to create small snippets of functionality, like say a message and then dial a new number. You can host Twimlets with Twilio, so you don't need your own server.