Created
June 12, 2017 04:43
-
-
Save tad-iizuka/c60e7878fea9fcf42a4cc688facca942 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
import requests | |
import json | |
import os | |
HEADER = { | |
'Content-type': 'application/json', | |
'Authorization': 'Bearer ' + 'Channel Access Token' | |
} | |
def lambda_handler(event, context): | |
body = json.loads(event['body']) | |
for event in body['events']: | |
payload = { | |
'replyToken': event['replyToken'], | |
'messages': [] | |
} | |
if event['message']['type'] == 'text': | |
payload['messages'].append({ | |
'type': 'text', | |
'text': event['message']['text'] | |
}) | |
elif event['message']['type'] == 'sticker': | |
payload['messages'].append({ | |
'type': 'sticker', | |
'stickerId': event['message']['stickerId'], | |
'packageId': event['message']['packageId'] | |
}) | |
if len(payload['messages']) > 0: | |
response = requests.post('https://api.line.me/v2/bot/message/reply', | |
headers=HEADER, | |
data=json.dumps(payload)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment