[Messaging API] How to re-use reply token to build a conversation

Dear all,

is there any way I can re-use the reply token in the messaging API? Example: User: Hello BOT: Hello. What is your order number? User: 123456 BOT: Thank you. Your order, 123456, will be delivered tomorrow.

How can I re-use the reply token within the messaging API to create the example conversation above? Usually, I can only use the reply_token once. Meaning, once I replied on the first "Hello", I cannot use the reply_token again. I need to wait for the user to send another message. However, the BOT does not know, that the second sentence is connected to the first message.

def handle_message(event):
    msg_from_user = event.message.text 
    line_bot_api.reply_message(event.reply_token, [TextSendMessage(text=message)])
`` `

  • 0
  • 1
  • 1863
  • twitter facebook

You can't re-use the token again but I understand that this is not the matter of reply_token but the one of keeping context. Like HTTP session of web application, you have to save the conversation context of each users to data store like RDBMS. On the second sentence come, get context from DB by userId and recognize what your bot should answer, then reply with the reply_token given in second request.

  • 1
本当によろしいですか? question.vm