You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Conversation tracking is the way I plan to implement a proper support for keyboards (as a layer above those) and forced replies.
@bot.command("support")defsupport_command(conversation, chat, message, args):
"""Ask for support"""conversation.start("support")
chat.send("Hey, what's your problem?", attach=conversation)
@bot.conversation("support")defbug_report_conversation(conversation, chat, message):
# First step is asking the user which problem he hasif"problem"notinconversation.data:
conversation.data["problem"] =message.textchat.send("OK! To which email address do you wish being contacted?",
attach=conversation)
else:
problem=conversation.data["problem"]
email=message.textmydb.add_ticket(problem, email)
chat.send("Thank you for contacting our support!")
conversation.end()
Let's break this down:
The /support command starts the support conversation: from this moment and until you close the conversation (or it times out) every message which is detected as part of the conversation will be routed to the relative function
The conversation is attached (the equivalent of the current extra argument) to the message you send to the user, and this acts as a Telegram ForceReply
Every message the user sends now is routed to the conversation function, so you can interact with your user more easily
Conversations have a dedicated shared memory, unique for every conversation, so you can store any information the user sent to you (it will be deleted after you end the conversation)
After you did what you want with the user, you can .end() the conversation.
I think conversations will aid you creating even more awesome bots, but if you have any idea please share it here!
Activity
patternspandemic commentedon Apr 8, 2016
I like this! I am excited to see this and keyboards in 0.3 target!
emilyalbini commentedon Apr 11, 2016
I'll probably redesign this API, I want to support multiple conversation steps from botogram.
dev72 commentedon Nov 16, 2017
Hi Pietro, is there currently a way to track conversations in botogram 0.4?