Make and install a bot
1
Make an app
In your organization’s settings, open Developer, then the Apps tab, and select New app. Give it the name
its posts should show, such as Deploy bot. For its icon, pick one of Mantle’s icons or an emoji, or upload an
image (PNG, GIF, WebP, JPEG or SVG, up to 1 MB). Without one, its posts show a bot icon. Organization owners and
admins make apps.
2
Install it in a workspace
Select the app. Its panel is a checklist for one workspace at a time: pick the workspace under Set up in, and
the next step to do is open. In Install, choose what it can do. Post messages (
chat:write) lets it post,
and Attach files (files:write) lets it attach files to its posts. Under It hears, pick
Messages that mention it (mentions:read, suggested), Every message (messages:read), or Nothing, and
whether People can message it (direct_messages:read) with direct messages. Select
Install. Workspace owners and admins install apps.3
Copy its token
Mantle shows the bot token once, in the Install step. Store it right away in your bot’s secret manager, for
example as
MANTLE_BOT_TOKEN, then select Done.4
Add it to channels
In the checklist’s Add it to a channel step, choose a channel and select Add. You can also add it from a
channel: open the ··· menu and choose Integrations, then Add source, and under Bots select the app.
A bot can only post to, and hear, the channels it has been added to.
If you lose the token, open the app on the Developer page, select Change on its Install step, then Rotate
token…. The old token stops working at once.
Check the token
GET /v1/me answers with the app, its workspace, and what it may do. Every request sends the token as a bearer token:
userId is the id the bot’s own posts carry as their author. GET /v1/channels lists the channels it has been added
to, as { "data": [{ "id", "name", "archived" }] }.
Post a message
Send aPOST to /v1/channels/{channelId}/messages with a JSON body that has a text field, files,
or both. The JavaScript examples use the SDK: install it with npm install @mantlechat/sdk. It runs on Node 20 or
later, Bun and Deno.
¹ A post with
files needs no text.
An Idempotency-Key header makes a retry safe: a repeat of the key answers with the first post and posts nothing new.
A post that went through answers 200:
duplicate is true when the request repeated an earlier Idempotency-Key. threadRootMessageId is there when the
post went into a thread.
The markdown follows the incoming webhooks rules: mentions don’t
notify anyone, images show as links, and HTML shows as text.
Edit or delete a post
A bot can change or delete its own posts, never anyone else’s. People see the change at once.PATCHtakestext,actions, or both; what you leave out stays as it is. It answers{ "messageId", "edited" }, andeditedisfalsewhen the post already read so.- New text shows the post as edited. Changing only its buttons doesn’t.
DELETEanswers204, also for a post that’s already deleted, so a retry is safe. The post shows as deleted, as a person’s does.
Attach files
A bot installed with Attach files (files:write) can attach files to its posts, as people do. It takes two steps:
ask Mantle for an upload, then send the bytes there. The bytes never go through Mantle’s API.
1
Start an upload
Send a
POST to /v1/files with the file’s name (1–255 characters), mimeType and size in bytes. It answers
201 with the file, and where and how to send its bytes:2
Send the bytes
PUT exactly size bytes to upload.url before expiresAt (5 minutes), with every header in upload.headers
and no bot token. A file can be uploaded once.3
Post it
Post with
files: [file.id], alone or with text. Post it within an hour: a file that isn’t posted by then is
removed.- Types: the ones people can attach in Mantle: JPEG, PNG, GIF and WebP images, PDF, plain text, Markdown, JSON, CSV,
and Word and Excel documents (
.docx,.xlsx). - Sizes: a file can be up to 5 MB on Free and 20 MB on a paid plan. A post can have 5 files and 25 MiB in all on Free, 10 files and 100 MiB on a paid plan. The plan is that of the person who installed the bot.
- Storage: files count toward the organization’s file storage, as people’s do.
- Each file goes on one post. Editing a post doesn’t change its files. Deleting the post deletes them.
Hear messages
A bot gets amessage.created event, signed so it can tell the event came from Mantle, for the messages it hears:
- With Messages that mention it, the ones that @-mention it or start with one of its commands.
- With Every message, each new message in its channels.
- With People can message it, each direct message a person sends it.
1
Give it an event URL
Once a bot that hears is installed, its checklist opens the Event URL step. Enter a public
https:// URL on
port 443 and select Save event URL.2
Copy its signing secret
Mantle shows the signing secret once, in the same step. Store it next to the token, for example as
MANTLE_WEBHOOK_SECRET.3
Send a test event
Check it answers opens next. Select Send test event: Mantle sends an
app.test event and shows how your URL
answered. The step is done once one is delivered.POST with a JSON body:
- A message is in a channel (
channelId) or a direct message (directMessageId): exactly one of the two is set. textis Markdown. Mentions read as@Nameand custom emoji as:shortcode:.threadRootMessageIdis the message whose thread this one is in, ornullfor a message in the channel itself.author.kindispersonorapp.authorisnullonce the author’s account is gone.aiGeneratedsays whether an AI model wrote the message, andmodelwhich one, such asdeepseek/deepseek-v4-flash. For a person’s or a bot’s post they arefalseandnull.message.mentions.appslists the bots the message mentions.mentionedsays whether this bot is one of them.commandis this bot’s slash command the message starts with, ornull.- A bot never gets its own posts. It does get other apps’ posts, up to a cap: a bot that answers bots should still make sure two of them can’t answer each other forever.
- Agent replies, and Linear, Stripe and Notion posts, aren’t sent. Incoming webhooks’ posts are, as an app’s.
- The text is read when the event is sent: a message edited first is sent as it is then, and one deleted first isn’t sent.
- Mantle may add fields to events. Ignore the ones you don’t know; the SDK does.
2xx within 10 seconds. Do slow work after you answer.
Apps answering apps
Two bots that answer each other’s posts would loop. So once apps have posted more than 30 messages in a minute in a channel, for the next 10 minutes their posts there reach no bot. People’s messages still do, and every post still shows in the channel. A retried post is counted once.Direct messages
A bot installed with People can message it (direct_messages:read) can be sent direct messages by the members of
its workspace. They find it under Bots in the new direct message dialog, in search, and as Message on its page
in a channel’s Integrations. The DM says the bot is a bot, and that what they send goes to its service.
Each direct message reaches the bot as a message.created event whose message.directMessageId is
set and channelId is null. It mentions nothing, so mentioned is false. The bot answers in the same conversation:
200 { "messageId", "duplicate" }, as a channel post does, and counts as unread for the person.
- A bot answers; it can’t start a DM. A person opens it first.
- Answering needs Post messages as well as People can message it, and the person still in the bot’s workspace.
- A DM has no threads, files, buttons or edits.
- If the bot stops taking messages (it’s paused, uninstalled, or People can message it is taken away), the person sees that it isn’t taking messages and can’t send it more.
Mentions
In a channel the bot is in, people can @-mention it from the composer’s@ menu, in the channel or in a thread. The
mention shows as a chip with the bot’s icon, and notifies no one. The bot gets the message with mentioned: true, as
@Deploy bot in text.
Slash commands
A bot can declare commands, which people pick from the composer’s/ menu at the start of a message, such as
/deploy production.
1
Declare them
Open the app on the Developer page and, in its Commands step, select Add commands. Give each a name, what it
does, and a usage hint such as
<environment>. Select Save commands. Commands are the same in every workspace.
Organization owners and admins declare them.2
Answer them
A message that starts with one of its commands reaches the bot whether it hears every message or only its mentions.
Its event’s
command says which, with the text after the name as args./deploy production, the event’s data has:
- A name is 1–32 lowercase letters, digits,
-or_. A description and a usage hint are up to 100 characters each. An app has up to 25 commands. - A command is an ordinary message: everyone in the channel sees it. Answer with a post, usually in its thread
(
replyToMessageId). - The
/menu offers a bot’s commands only while it can hear them: it’s installed, hears its mentions or every message, and has an event URL with its events not paused. - When two bots in a channel declare the same name, the one picked from the menu gets it. A typed command goes to a bot only when it’s the only one in the channel with that name.
Add buttons
A post can carry up to 5 buttons. Everyone who can see the post can click them, and the bot that posted them gets anaction.clicked event, whatever else it hears, as long as it has an event URL and is still in the channel. Otherwise
the person who clicked is told the app isn’t taking clicks.
A click is sent like a message, to the bot’s event URL:
useris who clicked;messageis the post the button is on.- Each click is sent once, even if its request is repeated. Two clicks, by one person or two, are two events: decide in your bot what a second click means.
- One person can click 20 times a minute in a workspace.
- Show what came of a click by editing the post, for example replacing its buttons with “Approved by Grace”, or by replying in its thread.
- The buttons stay until the bot changes or deletes the post. Send
"actions": []to take them away.
Check the signature
Every event has these headers:
Check the signature against the exact body you received, before parsing it, and refuse events more than 5 minutes old.
The SDK does all of this:
A small echo bot
This bot answers “pong” in the thread of any message that says “ping”, or uses its/ping command, with an Again
button that changes its answer. It runs on Bun: save it as bot.js, run bun add @mantlechat/sdk,
set the two environment variables, and run bun bot.js. Then use its public https:// address as the event URL, and
declare a ping command if you want one.
Retries and pausing
An event that fails is sent again after 10 seconds, 1 minute, 5 minutes, and 30 minutes. After the fifth failure, Mantle gives up on it.- Retried: network errors, timeouts, and the answers
408,409,425,429, and any5xx. - Not retried: any other
4xx, and a URL that isn’t a publichttps://address.
Errors
A refused request answers with an error body:Limits
Manage a bot
Open the app on the Developer page, pick the workspace under Set up in, and select Change on a step.- Install: change what it can do and select Save; its token stays. Rotate token… issues a new token, shown once; the old one stops working at once. Uninstall… removes it from the workspace: its token stops working and it leaves its channels. Its posts stay.
- Event URL: a new URL points its events somewhere else, with the same signing secret. Rotate signing secret… issues a new one, shown once, and Stop events… stops sending it messages.
- Edit, at the top of the app’s panel, changes its name, description and icon. Its earlier posts show the new name and icon too, in every workspace.
- Delete app…, in the app’s row menu, uninstalls it everywhere.
403 app_paused, and its
Install step needs attention. A workspace admin can select Install again there to give it a new token.
To take a bot out of one channel, open the channel’s Integrations, select the bot, and choose Remove from
channel. The person who added it, or a workspace admin, can.
Keep the token secret
The token can’t read a channel’s history or anything else in your workspace; a bot hears only the events Mantle sends it.Incoming webhooks
Post into one channel with a secret URL, no token.
Channels
Create channels and decide who can manage them.