Pancake
Pancake is a customer service inbox. The Pancake channel answers inbox messages, which Pancake calls INBOX, and post or page comments, which it calls COMMENT.
Setup
-
In Pancake, create a page access token for your page and note the page id. Pick a random webhook secret.
-
Store the values:
broods env set PANCAKE_PAGE_IDbroods env set PANCAKE_PAGE_ACCESS_TOKENbroods env set PANCAKE_WEBHOOK_SECRET -
Define the connection:
broods/index.tsimport { defineAgent, definePancakeConnection, env } from "broods";export const pancake = definePancakeConnection({pageId: env("PANCAKE_PAGE_ID"),pageAccessToken: env("PANCAKE_PAGE_ACCESS_TOKEN"),webhookSecret: env("PANCAKE_WEBHOOK_SECRET"),allowedChannelIds: ["*"],});export const myAgent = defineAgent({name: "my-agent",connections: [pancake],});Customer conversations are not known in advance, so a Pancake connection usually sets
allowedChannelIds: ["*"]. UsedefinePancakeChannelwith aconversationIdto give one conversation its own rules. -
Run
broods devorbroods deploy. Register the printed webhook URL in Pancake with the secret as a query parameter:https://gateway.broods.app/v1/webhooks/<accountId>/pancake?secret=<webhookSecret>Pancake does not sign webhooks, so the secret rides on the URL. A request without a matching
secretgets401.
Configuration
| Field | Required | Description |
|---|---|---|
pageId | yes | Pancake page id |
pageAccessToken | yes | page access token for API calls |
webhookSecret | yes | random value checked on every webhook request |
senderId | no | Pancake staff user the replies appear to come from |
allowedChannelIds | no | extra conversation ids, or ["*"] for every conversation |
allowedUserIds | no | customer ids allowed to trigger the agent. Everyone when omitted |
trace | no | "enabled" adds the dashboard trace link to replies |
partition | no | workspace folder split. See Workspaces |
Pancake has no chat commands. Slash text reaches the agent as ordinary input. A reply goes out in pieces of at most 1900 characters, under the Messenger limit Pancake relays to. Inbound photos and videos arrive as attachments. Pancake gets no reactions.
Human handoff
To let staff take over a conversation, tag it in Pancake and drop tagged messages in an onMessageReceived code hook. Every inbound message carries the conversation's tag ids on event.source.tagIds.
export const myAgent = defineAgent({
name: "my-agent",
connections: [pancake],
hooks: {
onMessageReceived: (ctx, event) => {
if (event.channel !== "pancake") return undefined;
const handoffTagIds = ["order-tag", "pending-tag"];
const tagIds = event.source.tagIds ?? [];
return tagIds.some((tagId) => handoffTagIds.includes(tagId))
? { drop: true }
: undefined;
},
},
});
Narrowing on event.channel gives event.source the Pancake type. Remove the tag in Pancake and the next customer message runs the agent again.
Hooks run in an isolated sandbox with no imports and no closure variables, so write the tag ids inline rather than reading them from a variable or env.
See Channels for channel tools and shared behavior.