Hi I have created a chatbot with pymessenger, flask, wit.ai. I have added some button but I dont know how to reply back once user press/select the option from my menu. Below is my code.
`@app.route('/', methods=['GET'])
def verify():
if request.args.get("hub.mode") == "subscribe" and request.args.get("hub.challenge"):
if not request.args.get("hub.verify_token") == "hello":
return "Verification token mismatch", 403
return request.args["hub.challenge"], 200
return "Hello World", 200
@app.route('/', methods=['POST'])
def webhook():
data = request.get_json()
log(data)
if data['object'] == 'page':
for entry in data['entry']:
for messaging_event in entry['messaging']:
sender_id = messaging_event['sender']['id']
recipient_id = messaging_event['recipient']['id']
if messaging_event.get('message'):
if 'text' in messaging_event['message']:
messaging_text = messaging_event['message']['text']
else:
messaging_text = 'no text'
response = None
entity, value = wit_response(messaging_text)
if entity == 'cust_id':
test = cust(str(value))
buttons = []
button = Button(title='1. Pizza', type='postback', payload='Pizza')
buttons.append(button)
button = Button(title='2. Burger', type='postback', payload='Burger')
buttons.append(button)
button = Button(title='3. Pasta', type='postback', payload='Pasta')
buttons.append(button)
text = 'Hey '+test[0] +'👋.'+"\n"+'Select Option:'
bot.send_button_message(sender_id, text, buttons)`
I Dont know after user chhoose one option how to handle request. For example if user select Pizza, I want to give pizza menu in text or button format.
Hi I have created a chatbot with pymessenger, flask, wit.ai. I have added some button but I dont know how to reply back once user press/select the option from my menu. Below is my code.
`@app.route('/', methods=['GET'])
I Dont know after user chhoose one option how to handle request. For example if user select Pizza, I want to give pizza menu in text or button format.