Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for tracking conversations #53

Open
pietroalbini opened this issue Apr 8, 2016 · 3 comments
Open

Add support for tracking conversations #53

pietroalbini opened this issue Apr 8, 2016 · 3 comments

Comments

@pietroalbini
Copy link
Contributor

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")
def support_command(conversation, chat, message, args):
    """Ask for support"""
    conversation.start("support")
    chat.send("Hey, what's your problem?", attach=conversation)

@bot.conversation("support")
def bug_report_conversation(conversation, chat, message):
    # First step is asking the user which problem he has
    if "problem" not in conversation.data:
        conversation.data["problem"] = message.text
        chat.send("OK! To which email address do you wish being contacted?",
                  attach=conversation)
    else:
        problem = conversation.data["problem"]
        email = message.text
        mydb.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!

@pietroalbini pietroalbini self-assigned this Apr 8, 2016
@pietroalbini pietroalbini added this to the botogram 0.3 milestone Apr 8, 2016
@patternspandemic
Copy link
Contributor

I like this! I am excited to see this and keyboards in 0.3 target!

@pietroalbini
Copy link
Contributor Author

I'll probably redesign this API, I want to support multiple conversation steps from botogram.

@pietroalbini pietroalbini removed their assignment Oct 1, 2016
@pietroalbini pietroalbini removed this from the botogram 0.4 milestone Jul 2, 2017
@dev72
Copy link

dev72 commented Nov 16, 2017

Hi Pietro, is there currently a way to track conversations in botogram 0.4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants