Imported from gokapso/whatsapp-support-agent (
AGENTS.md). Install upstream withnpx skills add gokapso/whatsapp-support-agent. Copyright stays with the author.
AGENTS.md
This file is for agents landing in whatsapp-support-agent for the first time.
Repo Purpose
This repo manages one Kapso example:
- one workflow:
whats-app-support-agent-example - one private function tool:
whatsapp-support-agent-ask-team-question - one public webhook function:
whatsapp-support-agent-slack-events - one inbound WhatsApp trigger on
WHATSAPP_PHONE_NUMBER_ID
The runtime flow is:
- WhatsApp message starts the workflow.
- The agent node answers directly when confident.
- If uncertain, the agent calls
ask_team_question, tells the user it is checking internally, then callsenter_waiting. - The support team replies in a Slack thread and sends
done. whatsapp-support-agent-slack-eventsaggregates the thread replies and resumes the waiting workflow.
Setup Flow
When a user asks to set up everything, do this:
- Read
README.md. - Run
bun install. - Copy
.env.exampleto.env.local. - Fill in
KAPSO_API_KEY,WHATSAPP_PHONE_NUMBER_ID,SLACK_BOT_TOKEN,SLACK_SIGNING_SECRET,SLACK_CHANNEL_ID, and optionalPROVIDER_MODEL_NAME. - Run
bun run validateandbun test. - Ensure
kapsois onPATH. For the unpublished local checkout, runexport PATH="$PWD/node_modules/.bin:$PATH". - Run
kapso link. - Run
kapso push. - Run
bun run sync:secrets. - Copy the printed Slack events URL into the Slack app Event Subscriptions page.
The repo is not fully configured until Slack points to the printed webhook URL and the bot is invited to SLACK_CHANNEL_ID.
Source Layout
functions/whatsapp-support-agent-ask-team-question/index.js: self-contained uploaded Worker handler.functions/whatsapp-support-agent-slack-events/index.js: self-contained uploaded Worker handler.functions/*/function.yaml: CLI function metadata.workflows/whats-app-support-agent-example/workflow.ts: source workflow built with@kapso/workflows.scripts/sync-secrets.js: temporary per-function secret sync helper.src/lib/: local helpers used by the workflow source, validation, and secret sync.
The generated workflow files workflows/*/workflow.yaml and workflows/*/definition.json are ignored in this scaffold because workflow.ts is the source of truth.
The CLI contract is simple: workflow.ts must default-export a Workflow instance. This scaffold also exports buildWorkflow() only so tests can rebuild the workflow after changing env vars.
Important Rules
- Function entrypoints must stay plain
async function handler(request, env)files. - Do not add
export defaultormodule.exportsto uploaded function files. whatsapp-support-agent-slack-eventsmust staypublic_endpoint: true.- Both functions must stay
invoke_response_mode: passthrough. - Use function slugs in workflow source, not function IDs.
- Do not manually edit generated workflow YAML/JSON unless intentionally moving to CLI-only JSON editing.
- Keep function secrets out of git; use
.env.localandbun run sync:secrets.
Advanced Repository Sandbox
To mount a GitHub repository into the support agent, set these in .env.local before kapso push:
AGENT_SANDBOX_GITHUB_REPO_URLAGENT_SANDBOX_GITHUB_REPO_BRANCH, defaults tomainAGENT_SANDBOX_GITHUB_PAT, empty is valid for public reposAGENT_SANDBOX_NETWORK_MODE, defaults toallow_listAGENT_SANDBOX_ALLOWED_OUTBOUND_HOSTS, comma-separated or newline-separatedAGENT_SANDBOX_ENABLED, optional explicittrueorfalse
This is scaffold-specific workflow code, not a Kapso CLI feature. When sandbox is enabled, workflow.ts adds raw agent config and prompt guidance telling the support agent to inspect the mounted repo before escalating repository-specific or code-specific questions to Slack.
Commands
bun run validate: local safety check for function source and workflow source.bun test: unit tests for Slack signature handling, KV state, aggregation, handlers, and workflow source.kapso push --dry-run: preview CLI changes.kapso push: build workflow source and push functions/workflow/trigger.bun run sync:secrets: sync function secrets after the functions exist remotely.
Recommended Extra Context
If you are using Codex or another skills-aware agent and want stronger Kapso-specific context, install:
npx skills add gokapso/kapso-agent-skills
This is not required for normal setup, but it helps when customizing the workflow graph, adding more Kapso functions, or debugging Kapso automation behavior.