Я пытаюсь создать приложение chatbot для мессенджера с помощью приложения фляги.Использование фляги с нгроком и пимесендером.Могу ли я изменить URL-адрес по умолчанию, который получает сообщение пользователя?Например: последовательность hello происходит в URL-адресе по умолчанию "/", после этого пользовательское сообщение должно быть отправлено в "/ login" и т. Д.
#We will receive messages that Facebook sends our bot at this endpoint
@app.route("/", methods=['GET', 'POST'])
def receive_message():
if request.method == 'GET':
"""Before allowing people to message your bot, Facebook has implemented a verify token
that confirms all requests that your bot receives came from Facebook."""
token_sent = request.args.get("hub.verify_token")
return verify_fb_token(token_sent)
#if the request was not get, it must be POST and we can just proceed with sending a message back to user
else:
# get whatever message a user sent the bot
output = request.get_json()
for event in output['entry']:
messaging = event['messaging']
for message in messaging:
if message.get('message'):
#Facebook Messenger ID for user so we know where to send response back to
recipient_id = message['sender']['id']
if message['message'].get('text'):
response_sent_text = get_message(recipient_id, message.get('message')['text'])
send_message(recipient_id, response_sent_text)
return redirect(url_for('pas2'))
#if user sends us a GIF, photo,video, or any other non-text item
if message['message'].get('attachments'):
response_sent_nontext = get_message_nontext(recipient_id, message.get('message'))
send_message(recipient_id, response_sent_nontext)
return "Message Processed"
@app.route("/login", methods = ['GET', 'POST'])
def pas2():
if request.method == 'GET':
"""Before allowing people to message your bot, Facebook has implemented a verify token
that confirms all requests that your bot receives came from Facebook."""
token_sent = request.args.get("hub.verify_token")
return verify_fb_token(token_sent)
else:
output = request.get_json()
for event in output['entry']:
messaging = event['messaging']
for message in messaging:
if message.get('message'):
#Facebook Messenger ID for user so we know where to send response back to
recipient_id = message['sender']['id']
if message['message'].get('text'):
response_sent_text = get_message(recipient_id, 'pas2')
send_message(recipient_id, response_sent_text)
return 'OK'
Это то, что у меня сейчас, яя плохо знаком с серверной частью.Спасибо.