There is no built-in way to hold a multi-step conversation. Developers who need to collect several pieces of information from a user in sequence have to manage state and event listeners by hand.
The idea is to introduce a @bot.dialog() decorator that provides a structured async API for step-by-step interactions. A dialog would expose ctx.ask() to send a prompt and ctx.next_message() to await the user's next reply in the same room, keeping the conversational state encapsulated in a single coroutine.
Proposed API
@bot.dialog("setup")
async def setup_dialog(ctx):
name = await ctx.ask("What's your name?")
await ctx.reply(f"Nice to meet you, {name}!")
The main design challenges are timeout handling (what happens if the user never replies), cancellation (the user starts a second dialog mid-way), and isolation (messages from other users in the same room should not be captured as answers). A timeout parameter on the decorator and a room+sender keyed wait queue on the bot are the most likely implementation paths. Also worth considering: whether dialogs should be re-entrant or exclusive per user per room.
There is no built-in way to hold a multi-step conversation. Developers who need to collect several pieces of information from a user in sequence have to manage state and event listeners by hand.
The idea is to introduce a
@bot.dialog()decorator that provides a structured async API for step-by-step interactions. A dialog would exposectx.ask()to send a prompt andctx.next_message()to await the user's next reply in the same room, keeping the conversational state encapsulated in a single coroutine.Proposed API
The main design challenges are timeout handling (what happens if the user never replies), cancellation (the user starts a second dialog mid-way), and isolation (messages from other users in the same room should not be captured as answers). A
timeoutparameter on the decorator and a room+sender keyed wait queue on the bot are the most likely implementation paths. Also worth considering: whether dialogs should be re-entrant or exclusive per user per room.