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
|`interaction_followup`|`interaction_token`, `content`|`req_id`| Send a follow-up response to a slash command |
209
+
|`interaction_respond`|`interaction_token`, `content`|`embed`, `components`, `ephemeral`, `req_id`| Immediate response to a component interaction |
210
+
|`interaction_edit`|`interaction_token`|`content`, `embed`, `components`, `req_id`| Edit the original interaction message |
211
+
|`interaction_followup`|`interaction_token`, `content`|`embed`, `components`, `req_id`| Send a follow-up response to a slash command |
212
+
|`modal_send`|`interaction_token`, `title`, `custom_id`, `fields`|`req_id`| Open a modal form in response to a component interaction |
195
213
196
214
<Callouttype="note">
197
215
Slash command interactions are automatically deferred with a "thinking" indicator. You must respond with either `interaction_followup` or `stream_start` (with the `interaction_token`) within 15 minutes, per Discord's limits.
@@ -226,12 +244,18 @@ Streaming lets you progressively update a single message, similar to how ChatGPT
226
244
|`thread_create`|`channel_id`, `name`|`message_id`, `auto_archive_duration`, `content`, `req_id`| Create a thread (optionally from a message) |
227
245
|`thread_send`|`thread_id`, `content`|`files`, `req_id`| Send a message to a thread |
228
246
|`thread_list`|`channel_id`|`req_id`| List threads in a channel |
247
+
|`thread_archive`|`thread_id`|`req_id`| Archive a thread |
248
+
|`thread_rename`|`thread_id`, `name`|`req_id`| Rename a thread |
249
+
|`thread_add_member`|`thread_id`, `user_id`|`req_id`| Add a member to a thread |
250
+
|`thread_remove_member`|`thread_id`, `user_id`|`req_id`| Remove a member from a thread |
The protocol currently supports **54 actions** and **17 event types**. See the [Serve Actions](/reference/serve-actions) and [Serve Events](/reference/serve-events) references for the complete list.
Copy file name to clipboardExpand all lines: docs/guides/building-agents.mdx
+58Lines changed: 58 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -794,6 +794,64 @@ if __name__ == "__main__":
794
794
795
795
---
796
796
797
+
## AI Serve Agent (`ai_serve_agent.py`)
798
+
799
+
Beyond the five levels above, discli ships with an example AI-powered agent that combines Claude (via the Anthropic Agent SDK) with `discli serve`. This is the recommended architecture for building intelligent Discord agents.
800
+
801
+
### Architecture
802
+
803
+
The AI serve agent uses a two-layer approach:
804
+
805
+
1.**Claude Agent SDK** provides the reasoning and decision-making layer
806
+
2.**`discli serve`** provides the persistent Discord connection via JSONL
807
+
3.**Bash tool calls** let Claude execute discli CLI commands for most operations (send messages, manage channels, list members, etc.)
808
+
4.**Component blocks** let Claude declare rich UI elements inline
809
+
810
+
Claude reads events from `discli serve` stdout and decides how to respond. For standard actions, it runs CLI commands through Bash. For interactive UI elements like buttons, select menus, and modals, it uses fenced component blocks.
811
+
812
+
### Component blocks
813
+
814
+
The agent uses a special fenced code block syntax to declare message components:
The agent framework parses these blocks and sends them as JSONL actions to `discli serve`.
835
+
836
+
### Modal registry pattern
837
+
838
+
Modals require a two-step flow: first you send the modal to the user (`modal_send`), then you handle their submission (`modal_submit` event). The agent maintains a modal registry that maps `custom_id` values to handler functions, so when a `modal_submit` event arrives, the agent knows which handler to invoke.
839
+
840
+
### Example test messages
841
+
842
+
Try these messages to exercise the agent's capabilities:
843
+
844
+
-`@bot send a poll about favorite languages` -- creates a poll with buttons
845
+
-`@bot show me server info` -- runs `discli server info` via Bash
846
+
-`@bot create a feedback form` -- opens a modal dialog
847
+
-`@bot set up a welcome channel` -- orchestrates channel creation and permissions
848
+
849
+
### Running the example
850
+
851
+
See [`agents/ai_serve_agent.py`](/agents/ai_serve_agent.py) for the full implementation. The agent requires the `anthropic` Python package and a valid `ANTHROPIC_API_KEY` environment variable.
0 commit comments