Skip to content

Commit 9c21fb3

Browse files
committed
docs(bot): add local webhook example
1 parent 318affa commit 9c21fb3

1 file changed

Lines changed: 49 additions & 9 deletions

File tree

  • apps/docs-website/src/content/docs/guides/integrations

apps/docs-website/src/content/docs/guides/integrations/bots.mdx

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ bot's profile shows its purpose, data-handling description, and the application
1010
capabilities its owner or a server administrator approved.
1111

1212
<Aside type="caution">
13-
Bot APIs are experimental in Chatto 0.5. Pin and test the server versions your integration supports, and treat capability identifiers as unstable until Chatto reaches 1.0.
13+
Bot APIs are experimental in Chatto 0.5. Pin and test the server versions your
14+
integration supports, and treat capability identifiers as unstable until
15+
Chatto reaches 1.0.
1416
</Aside>
1517

1618
## The Authorization Model
@@ -28,11 +30,11 @@ self-join rooms.
2830

2931
## Initial Capabilities
3032

31-
| Capability | Allows |
32-
| ---------- | ------ |
33-
| `dm.messages.read` | Listing and reading complete histories of DMs in which the bot is an explicit participant. Users cannot start a DM with the bot without this grant. |
34-
| `thread.messages.read` | Listing and reading only channel threads where an installed bot was directly mentioned. |
35-
| `messages.write` | Posting text messages in explicit DMs and invited threads, or posting root text messages through the incoming webhook to an explicitly installed channel. |
33+
| Capability | Allows |
34+
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
35+
| `dm.messages.read` | Listing and reading complete histories of DMs in which the bot is an explicit participant. Users cannot start a DM with the bot without this grant. |
36+
| `thread.messages.read` | Listing and reading only channel threads where an installed bot was directly mentioned. |
37+
| `messages.write` | Posting text messages in explicit DMs and invited threads, or posting root text messages through the incoming webhook to an explicitly installed channel. |
3638

3739
Use `BotService.ListApplicationCapabilities` instead of hard-coding this table.
3840
The response is the exhaustive catalogue understood by that server and includes
@@ -45,6 +47,10 @@ Bot creation issues one show-once API key. Send it as a bearer token only to
4547
protected asset endpoints, room directory, and self-join operations reject bot
4648
keys even when the key itself is valid.
4749

50+
The bot owner can reset an active key, and a server administrator can revoke
51+
it. A revoked bot has no API access until its owner selects **Generate API key**
52+
and copies the new show-once secret.
53+
4854
The bot runtime API supports listing explicit bot DMs and invited threads,
4955
reading their timeline pages, and posting text messages in those contexts. Use
5056
the opaque timeline cursors unchanged and never derive storage coordinates from
@@ -74,6 +80,28 @@ token:
7480
}
7581
```
7682

83+
For a bot in the local `mise dev` stack, copy the bot ID from its settings URL
84+
and the channel room ID from the channel URL. Then run:
85+
86+
```sh
87+
CHATTO_URL="http://localhost:${CONDUCTOR_PORT:-4000}"
88+
BOT_ID="paste-bot-id"
89+
ROOM_ID="paste-channel-room-id"
90+
BOT_API_KEY="paste-show-once-api-key"
91+
92+
curl --fail-with-body --request POST \
93+
"$CHATTO_URL/webhooks/bots/$BOT_ID" \
94+
--header "Authorization: Bearer $BOT_API_KEY" \
95+
--header "Content-Type: application/json" \
96+
--data "{\"room_id\":\"$ROOM_ID\",\"body\":\"Hello from curl!\"}"
97+
```
98+
99+
Before sending the request, add the bot to the channel and grant it the
100+
`messages.write` capability. A successful request returns HTTP `201` and posts
101+
the message as the bot. In a Conductor workspace, `CONDUCTOR_PORT` points at
102+
that workspace's frontend proxy; outside Conductor, `mise dev` defaults to port
103+
`4000`.
104+
77105
The endpoint can only create a root text message in a channel where the bot is
78106
explicitly installed. It cannot read or enumerate anything. Delivery is at
79107
least once: retrying after an uncertain response can create a duplicate, so
@@ -87,7 +115,19 @@ server-authored capability list on public profile cards, so users can make an
87115
informed choice before starting a DM.
88116

89117
<CardGrid>
90-
<LinkCard title="Bot Management API" href="/reference/connectrpc-api/bots/" description="Create bots, rotate keys, and approve capabilities." />
91-
<LinkCard title="Bot Runtime API" href="/reference/connectrpc-api/bot-runtime/" description="Capability-gated operations for bot API keys." />
92-
<LinkCard title="API Compatibility" href="/guides/integrations/api-compatibility/" description="Version-skew and experimental API guidance." />
118+
<LinkCard
119+
title="Bot Management API"
120+
href="/reference/connectrpc-api/bots/"
121+
description="Create bots, rotate keys, and approve capabilities."
122+
/>
123+
<LinkCard
124+
title="Bot Runtime API"
125+
href="/reference/connectrpc-api/bot-runtime/"
126+
description="Capability-gated operations for bot API keys."
127+
/>
128+
<LinkCard
129+
title="API Compatibility"
130+
href="/guides/integrations/api-compatibility/"
131+
description="Version-skew and experimental API guidance."
132+
/>
93133
</CardGrid>

0 commit comments

Comments
 (0)