Skip to content

Instantly share code, notes, and snippets.

@jeanfrancis
Forked from kwhinnery/main.js
Last active August 29, 2015 14:16
Show Gist options
  • Save jeanfrancis/662268dce9afbb428c8c to your computer and use it in GitHub Desktop.
Save jeanfrancis/662268dce9afbb428c8c to your computer and use it in GitHub Desktop.
// Use Parse's RPC functionality to make an outbound call
Parse.Cloud.define('makeCall', function(request, response) {
// Create a Twilio REST API client - get your account SID and
// auth token at https://www.twilio.com/user/account
var client = new twilio.RestClient(
'YOUR_ACCOUNT_SID', // Account SID
'YOUR_AUTH_TOKEN' // auth token
);
// Place an outbound call
client.makeCall({
to: request.params.to, // the number you wish to call
from: '+16515557777', // a valid Twilio number you own
url: 'https://chunky-danger-monkey.parseapp.com/hello', // TwiML URL
method: 'GET' // HTTP method with which to fetch the TwiML
}, function(error, data) {
// Handle the result of placing the outbound call
if (error) {
response.error('there was a problem :(');
} else {
response.success('call incoming!');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment