Skip to content

Instantly share code, notes, and snippets.

@jkeefe
Created September 6, 2016 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkeefe/c013ea91f4cfaf95ecef2a51b9c77f13 to your computer and use it in GitHub Desktop.
Save jkeefe/c013ea91f4cfaf95ecef2a51b9c77f13 to your computer and use it in GitHub Desktop.
Example of a lamba.js file for a Twilio bot
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