-
-
Save jeanfrancis/662268dce9afbb428c8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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