Skip to content

Instantly share code, notes, and snippets.

@jagrament
Last active May 22, 2018 11:13
Show Gist options
  • Save jagrament/017b430a0b15778ad5bfdfd2efa44057 to your computer and use it in GitHub Desktop.
Save jagrament/017b430a0b15778ad5bfdfd2efa44057 to your computer and use it in GitHub Desktop.
CGS Lambda sample for Expert Agent Developer Dashboard (https://developers.sebastien.ai)
'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