Last active
May 22, 2018 11:13
-
-
Save jagrament/017b430a0b15778ad5bfdfd2efa44057 to your computer and use it in GitHub Desktop.
CGS Lambda sample for Expert Agent Developer Dashboard (https://developers.sebastien.ai)
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
'use strict'; | |
console.log('Loading function'); | |
exports.handler = (event, context, callback) => { | |
const done = (err, res) => callback(null, { | |
statusCode: err ? '400' : '200', | |
body: err ? err.message : JSON.stringify(res), | |
headers: { | |
'Content-Type': 'application/json', | |
}, | |
}); | |
switch (event.httpMethod) { | |
case 'POST': | |
console.log(event.body); | |
const payload = JSON.parse(event.body); | |
const response = { | |
"error_code": "success", | |
"status": "true", | |
"user_id": payload["user_id"], | |
"bot_id": payload["bot_id"], | |
"params": { | |
"status": "200", | |
"message": payload["args"]["location"][0] + "の天気は晴れです。" | |
} | |
}; | |
done(null,response); | |
break; | |
default: | |
done(new Error(`Unsupported method "${event.httpMethod}"`)); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment