Python Handy Webhook Handler For Using KaKao Plus Friend Auto Reply
Inspired By : https://github.com/conbus/fbmq
pip install kakaoplus
Handle kakaotalk plus friend auto_reply
from flask import Flask, request
from kakao import KaKaoAgent
app = Flask(__name__)
KaKao = KaKaoAgent()
@app.route('/keyboard', methods=['GET'])
def keyboard_handler():
res = KaKao.handle_keyboard_webhook()
return res
@app.route('/message', methods=['POST'])
def message_handler():
req = request.get_data(as_text=True)
res = KaKao.handle_webhook(req)
return res
@KaKao.handle_keyboard
def keyboard_handler(res):
'''
:param req: request from kakao
:param res: response
'''
res.keyboard_buttons = [
'button1',
'button2',
'button3'
]
@KaKao.handle_message
def handle_message(req, res):
'''
:param req: request from kakao
:param res: response
'''
echo_message = req.content
res.text = "Echo Message: " + echo_message
@KaKao.handle_message(['hello', 'hi'])
def greeting_callback(req, res):
'''
:param req: request from kakao
:param res: response
'''
res.text = "Hello :)"