Code-Society-Lab / Code-Society-Lab/matrixpy

Dialog

Open
#92 0 comments 0 reactions 0 assignees View on GitHub
blocked feature
Dominant language
Python
Stars
14
Forks
7
Avg merge
8d 19h
Merged PRs (30d)
5

Description

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**
```python
@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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.