# `ExGram.FSM.Key.ChatTopic`
[🔗](https://github.com/rockneurotiko/ex_gram_fsm/blob/v0.1.0/lib/ex_gram/fsm/key/chat_topic.ex#L1)

FSM key: `{chat_id, thread_id}`.

Scopes FSM state per forum topic, shared by all users in that topic. This is
useful for Telegram groups with Topics (forum mode) enabled, where you want
each topic to carry its own independent conversation flow.

## Key shape

| Update type | Key |
|-------------|-----|
| Message in a forum topic | `{chat_id, thread_id}` |
| Message outside a topic | `{chat_id, 0}` — 0 is a sentinel for no-topic context |
| Inline query (no chat) | `:error` — FSM state is skipped |

## Accessing thread_id

The `message_thread_id` field is read from:
1. `update.message.message_thread_id` — for regular messages
2. `update.callback_query.message.message_thread_id` — for callback queries

---

*Consult [api-reference.md](api-reference.md) for complete listing*
