Skip to content

Instantly share code, notes, and snippets.

@jagrament
Last active September 20, 2017 10:21
Show Gist options
  • Save jagrament/3e00d41097182ef250fc9a10012f79ae to your computer and use it in GitHub Desktop.
Save jagrament/3e00d41097182ef250fc9a10012f79ae to your computer and use it in GitHub Desktop.
import boto3
import json
print('Loading function')
def respond(err, res=None):
return {
"headers":{"Content-Type": "application/json"},
'statusCode': 200,
'body' : json.dumps(res)
}
def lambda_handler(event, context):
payload = json.loads(event['body'])
if payload['args']['intent'] == 'weather':
response_body = {"error_code": "success", "status": "true", "user_id": payload["user_id"], "params": {"status": "200", "message": payload["args"]["location"] + "の天気は晴れです。"}, "bot_id": payload["bot_id"]}
return respond(None, response_body)
else:
return respond(None, {"error_code": "success", "status": "true", "user_id": payload["user_id"], "bot_id": payload["bot_id"], "params": {"status": "true", "message": "そのIntentには対応していません。"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment