Reputation: 979
we are developing a mobile (iOS/Android) application through which the user can send an automatic Twilio phone call (using Parse Cloud Code) to a number of her/his choice. Is it possible to dynamically set the content of the phone call from the client (like one can do with SMS’s by passing a string as a variable)? From the examples in the Parse/Twilio documentation it seems that this is not the case and one can only set in advance different texts at different URL’s and choose between them. Is it so?
Upvotes: 1
Views: 437
Reputation: 73027
Twilio developer evangelist here.
You can dynamically set phone call content from a single URL by adding URL parameters to the URL you set for the phone call. So, if, for example, you created a call like so:
client.makeCall({
to: NUMBER,
from: YOUR_TWILIO_NUMBER,
url: 'http://example.com/call/?name=Phil'
}, function(err, responseData) {
// call is made
});
Then you can use the name
parameter in the callback to alter the response. Here's an example route in express:
app.post('/call', function(req, res) {
responseText = "Hello " + req.query.name;
res.send("<Response><Say>" + responseText + "</Say></Response>");
});
I hope this helps, let me know if you have any other questions.
Upvotes: 4