Created
September 6, 2016 03:22
-
-
Save jkeefe/c013ea91f4cfaf95ecef2a51b9c77f13 to your computer and use it in GitHub Desktop.
Example of a lamba.js file for a Twilio bot
This file contains 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
var questionbot = require('./index'); | |
var ApiBuilder = require('claudia-api-builder'); | |
var api = new ApiBuilder(); | |
module.exports = api; | |
api.post('/question-bot', function(request){ | |
// bulding the reply (repsonse) | |
// which first sends the request object to sparkbot for processing | |
return questionbot(request) | |
// wait for the Promise object to come back from sparkbot | |
.then(function(response){ | |
// send the response back to the requester (Twilio) | |
return response; | |
}); | |
}, { | |
// this optional 3rd argument changes the format of the response, for twilio | |
success: { contentType: 'application/xml' }, | |
error: { contentType: 'application/xml' } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment