* (`<base>/hooks/…`) takes these calls too, so a Cloud and a self-hosted edge need no second route. */
export const BOT_API_KEY_PLACEHOLDER = "YOUR_KEY";
export const BOT_API_UPGRADE = "Bot API comes with a higher plan. Upgrade this Cloud to use it.";
export function botApiEndpoint(hooksBaseUrl: string, botId: string): string {
return `${hooksBaseUrl.replace(/\/+$/, "")}/hooks/api/bots/${encodeURIComponent(botId)}/messages`;
}
export function botApiCurl(endpoint: string, key: string = BOT_API_KEY_PLACEHOLDER): string {
return [
`curl -X POST "${endpoint}" \\`,
` -H "Authorization: Bearer ${key}" \\`,
` -H "Content-Type: application/json" \\`,
` -d '{"message": "Hello! What can you do?"}'`,
].join("\n");
}
export type BotApiReply =
| { reply: string; thread: string }
| { thread: string; status: "working" | "needs_approval" };