Created
September 25, 2015 17:41
-
-
Save akjordan/461ab7fcc476bd9a775d to your computer and use it in GitHub Desktop.
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
console.log('Loading function'); | |
exports.handler = function(event, context) { | |
var output ='<?xml version="1.0" encoding="UTF-8"?><Response><Pause length="2"/><Say>Hello Amazon, this is Twilio powered by Lambda</Say></Response>'; | |
context.succeed(output); | |
}; | |
// Twilio sends requests with content type application/x-www-form-urlencoded | |
// To enable API gateway to parse them you need to go to Integration Request | |
// Under Integration Request go to Mapping Templates and set content type to | |
// application/x-www-form-urlencoded and select Mapping Template of type Empty | |
// Save your mapping template | |
// Screenshot of complete config: http://cl.ly/image/450F321o1X2O | |
// By default lambda will try to render the response as JSON which will break TwiML | |
// To override you need to go to Integration Response then Mapping Templates | |
// Create a new Mapping Template with the following code | |
// #set($inputRoot = $input.path('$')) | |
// $inputRoot | |
// Save this new mapping | |
// Screenshot of complete config: http://cl.ly/image/363O3p1V2s3t | |
// Lastly you need to make sure the respnse is returned in XML instead of JSON | |
// To configure this go to Method Response, expand the 200 tab and add a new | |
// Response Models for 200 entry. Set content type to application/xml and save | |
// Screenshot of complete config: http://cl.ly/image/1v1E3u2d3i1m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment