$npx -y skills add SamarthaKV29/antigravity-god-mode --skill automate-whatsappBuild WhatsApp automations with Kapso workflows: configure WhatsApp triggers, edit workflow graphs, manage executions, deploy functions, and use databases/integrations for state. Use when automating WhatsApp conversations and event handling.
| 1 | # Automate WhatsApp |
| 2 | |
| 3 | ## When to use |
| 4 | |
| 5 | Use this skill to build and run WhatsApp automations: workflow CRUD, graph edits, triggers, executions, function management, app integrations, and D1 database operations. |
| 6 | |
| 7 | ## Setup |
| 8 | |
| 9 | Env vars: |
| 10 | - `KAPSO_API_BASE_URL` (host only, no `/platform/v1`) |
| 11 | - `KAPSO_API_KEY` |
| 12 | |
| 13 | ## How to |
| 14 | |
| 15 | ### Edit a workflow graph |
| 16 | |
| 17 | 1. Fetch graph: `node scripts/get-graph.js <workflow_id>` (note the `lock_version`) |
| 18 | 2. Edit the JSON (see graph rules below) |
| 19 | 3. Validate: `node scripts/validate-graph.js --definition-file <path>` |
| 20 | 4. Update: `node scripts/update-graph.js <workflow_id> --expected-lock-version <n> --definition-file <path>` |
| 21 | 5. Re-fetch to confirm |
| 22 | |
| 23 | For small edits, use `edit-graph.js` with `--old-file` and `--new-file` instead. |
| 24 | |
| 25 | If you get a lock_version conflict: re-fetch, re-apply changes, retry with new lock_version. |
| 26 | |
| 27 | ### Manage triggers |
| 28 | |
| 29 | 1. List: `node scripts/list-triggers.js <workflow_id>` |
| 30 | 2. Create: `node scripts/create-trigger.js <workflow_id> --trigger-type <type> --phone-number-id <id>` |
| 31 | 3. Toggle: `node scripts/update-trigger.js --trigger-id <id> --active true|false` |
| 32 | 4. Delete: `node scripts/delete-trigger.js --trigger-id <id>` |
| 33 | |
| 34 | For inbound_message triggers, first run `node scripts/list-whatsapp-phone-numbers.js` to get `phone_number_id`. |
| 35 | |
| 36 | ### Debug executions |
| 37 | |
| 38 | 1. List: `node scripts/list-executions.js <workflow_id>` |
| 39 | 2. Inspect: `node scripts/get-execution.js <execution-id>` |
| 40 | 3. Get value: `node scripts/get-context-value.js <execution-id> --variable-path vars.foo` |
| 41 | 4. Events: `node scripts/list-execution-events.js <execution-id>` |
| 42 | |
| 43 | ### Create and deploy a function |
| 44 | |
| 45 | 1. Write code with handler signature (see function rules below) |
| 46 | 2. Create: `node scripts/create-function.js --name <name> --code-file <path>` |
| 47 | 3. Deploy: `node scripts/deploy-function.js --function-id <id>` |
| 48 | 4. Verify: `node scripts/get-function.js --function-id <id>` |
| 49 | |
| 50 | ### Set up agent node with app integrations |
| 51 | |
| 52 | 1. Find model: `node scripts/list-provider-models.js` |
| 53 | 2. Find account: `node scripts/list-accounts.js --app-slug <slug>` (use `pipedream_account_id`) |
| 54 | 3. Find action: `node scripts/search-actions.js --query <word> --app-slug <slug>` (action_id = key) |
| 55 | 4. Create integration: `node scripts/create-integration.js --action-id <id> --app-slug <slug> --account-id <id> --configured-props <json>` |
| 56 | 5. Add tools to agent node via `flow_agent_app_integration_tools` |
| 57 | |
| 58 | ### Database CRUD |
| 59 | |
| 60 | 1. List tables: `node scripts/list-tables.js` |
| 61 | 2. Query: `node scripts/query-rows.js --table <name> --filters <json>` |
| 62 | 3. Create/update/delete with row scripts |
| 63 | |
| 64 | ## Graph rules |
| 65 | |
| 66 | - Exactly one start node with `id` = `start` |
| 67 | - Never change existing node IDs |
| 68 | - Use `{node_type}_{timestamp_ms}` for new node IDs |
| 69 | - Non-decide nodes have 0 or 1 outgoing `next` edge |
| 70 | - Decide edge labels must match `conditions[].label` |
| 71 | - Edge keys are `source`/`target`/`label` (not `from`/`to`) |
| 72 | |
| 73 | For full schema details, see `references/graph-contract.md`. |
| 74 | |
| 75 | ## Function rules |
| 76 | |
| 77 | ```js |
| 78 | async function handler(request, env) { |
| 79 | // Parse input |
| 80 | const body = await request.json(); |
| 81 | // Use env.KV and env.DB as needed |
| 82 | return new Response(JSON.stringify({ result: "ok" })); |
| 83 | } |
| 84 | ``` |
| 85 | |
| 86 | - Do NOT use `export`, `export default`, or arrow functions |
| 87 | - Return a `Response` object |
| 88 | |
| 89 | ## Execution context |
| 90 | |
| 91 | Always use this structure: |
| 92 | - `vars` - user-defined variables |
| 93 | - `system` - system variables |
| 94 | - `context` - channel data |
| 95 | - `metadata` - request metadata |
| 96 | |
| 97 | ## Scripts |
| 98 | |
| 99 | ### Workflows |
| 100 | |
| 101 | | Script | Purpose | |
| 102 | |--------|---------| |
| 103 | | `list-workflows.js` | List workflows (metadata only) | |
| 104 | | `get-workflow.js` | Get workflow metadata | |
| 105 | | `create-workflow.js` | Create a workflow | |
| 106 | | `update-workflow-settings.js` | Update workflow settings | |
| 107 | |
| 108 | ### Graph |
| 109 | |
| 110 | | Script | Purpose | |
| 111 | |--------|---------| |
| 112 | | `get-graph.js` | Get workflow graph + lock_version | |
| 113 | | `edit-graph.js` | Patch graph via string replacement | |
| 114 | | `update-graph.js` | Replace entire graph | |
| 115 | | `validate-graph.js` | Validate graph structure locally | |
| 116 | |
| 117 | ### Triggers |
| 118 | |
| 119 | | Script | Purpose | |
| 120 | |--------|---------| |
| 121 | | `list-triggers.js` | List triggers for a workflow | |
| 122 | | `create-trigger.js` | Create a trigger | |
| 123 | | `update-trigger.js` | Enable/disable a trigger | |
| 124 | | `delete-trigger.js` | Delete a trigger | |
| 125 | | `list-whatsapp-phone-numbers.js` | List phone numbers for trigger setup | |
| 126 | |
| 127 | ### Executions |
| 128 | |
| 129 | | Script | Purpose | |
| 130 | |--------|---------| |
| 131 | | `list-executions.js` | List executions | |
| 132 | | `get-execution.js` | Get execution details | |
| 133 | | `get-context-value.js` | Read value from execution context | |
| 134 | | `update-execution-status.js` | Force execution state | |
| 135 | | `resume-execution.js` | Resume waiting execution | |
| 136 | | `l |