From 16c0f6185e455b4e464bd1b381ef4137c379a57c Mon Sep 17 00:00:00 2001 From: poozx10rr <51429057+poozx10rr@users.noreply.github.com> Date: Thu, 3 Oct 2019 13:37:41 +0700 Subject: [PATCH] Update app.py --- app.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 71afb8a4..d5f919ca 100644 --- a/app.py +++ b/app.py @@ -8,7 +8,7 @@ @app.route('/') def index(): a=os.environ['Authorization'] - return "นายอาคม สุวรรณประเสริฐ เลขที่ 0 ชั้น ม.4/3" + return "นายสิทธิกร อุติ เลขที่ 6 ชั้น ม.4/3" @app.route("/webhook", methods=['POST']) def webhook(): @@ -20,11 +20,15 @@ def callback(): json_line = request.get_json() json_line = json.dumps(json_line) decoded = json.loads(json_line) - user = decoded["events"][0]['replyToken'] - userText = decoded["events"][0]['message']['text'] - sendText(user,userText) - return '',200 - + user = decoded['originalDectIntentRequest']['payload']['data']['replyToken'] + userText = decoded["queryResult"]['intent']['displayName'] + if (userText == 'สวัสดี') : + sendText(user,'ดีครับ') + elif (userText == 'ทำไรอยู่') : + sendText(user,'ทำงาน') + else : + sendText(user,'ทำงานต่อเเปป + return '',200 def sendText(user, text): LINE_API = 'https://api.line.me/v2/bot/message/reply' headers = {