automate-whatsapp

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Automate WhatsApp

WhatsApp自动化

When to use

适用场景

Use this skill to build and run WhatsApp automations: workflow CRUD, graph edits, triggers, executions, function management, app integrations, and D1 database operations.
使用本技能构建并运行WhatsApp自动化:工作流增删改查(CRUD)、流程图编辑、触发器配置、执行管理、函数管理、应用集成以及D1数据库操作。

Setup

配置步骤

Env vars:
  • KAPSO_API_BASE_URL
    (host only, no
    /platform/v1
    )
  • KAPSO_API_KEY
环境变量:
  • KAPSO_API_BASE_URL
    (仅需主机地址,无需
    /platform/v1
  • KAPSO_API_KEY

How to

操作指南

Edit a workflow graph

编辑工作流图

  1. Fetch graph:
    node scripts/get-graph.js <workflow_id>
    (note the
    lock_version
    )
  2. Edit the JSON (see graph rules below)
  3. Validate:
    node scripts/validate-graph.js --definition-file <path>
  4. Update:
    node scripts/update-graph.js <workflow_id> --expected-lock-version <n> --definition-file <path>
  5. Re-fetch to confirm
For small edits, use
edit-graph.js
with
--old-file
and
--new-file
instead.
If you get a lock_version conflict: re-fetch, re-apply changes, retry with new lock_version.
  1. 获取流程图:
    node scripts/get-graph.js <workflow_id>
    (注意记录
    lock_version
  2. 编辑JSON文件(请遵循下方的流程图规则)
  3. 验证:
    node scripts/validate-graph.js --definition-file <path>
  4. 更新:
    node scripts/update-graph.js <workflow_id> --expected-lock-version <n> --definition-file <path>
  5. 重新获取以确认修改
若仅需小改动,可使用
edit-graph.js
搭配
--old-file
--new-file
参数替代上述步骤。
若遇到
lock_version
冲突:重新获取流程图,重新应用修改,使用新的
lock_version
重试。

Manage triggers

管理触发器

  1. List:
    node scripts/list-triggers.js <workflow_id>
  2. Create:
    node scripts/create-trigger.js <workflow_id> --trigger-type <type> --phone-number-id <id>
  3. Toggle:
    node scripts/update-trigger.js --trigger-id <id> --active true|false
  4. Delete:
    node scripts/delete-trigger.js --trigger-id <id>
For inbound_message triggers, first run
node scripts/list-whatsapp-phone-numbers.js
to get
phone_number_id
.
  1. 列出触发器:
    node scripts/list-triggers.js <workflow_id>
  2. 创建触发器:
    node scripts/create-trigger.js <workflow_id> --trigger-type <type> --phone-number-id <id>
  3. 启用/禁用触发器:
    node scripts/update-trigger.js --trigger-id <id> --active true|false
  4. 删除触发器:
    node scripts/delete-trigger.js --trigger-id <id>
配置
inbound_message
触发器前,需先运行
node scripts/list-whatsapp-phone-numbers.js
获取
phone_number_id

Debug executions

调试执行流程

  1. List:
    node scripts/list-executions.js <workflow_id>
  2. Inspect:
    node scripts/get-execution.js <execution-id>
  3. Get value:
    node scripts/get-context-value.js <execution-id> --variable-path vars.foo
  4. Events:
    node scripts/list-execution-events.js <execution-id>
  1. 列出执行记录:
    node scripts/list-executions.js <workflow_id>
  2. 查看执行详情:
    node scripts/get-execution.js <execution-id>
  3. 获取上下文变量值:
    node scripts/get-context-value.js <execution-id> --variable-path vars.foo
  4. 查看执行事件:
    node scripts/list-execution-events.js <execution-id>

Create and deploy a function

创建并部署函数

  1. Write code with handler signature (see function rules below)
  2. Create:
    node scripts/create-function.js --name <name> --code-file <path>
  3. Deploy:
    node scripts/deploy-function.js --function-id <id>
  4. Verify:
    node scripts/get-function.js --function-id <id>
  1. 编写符合处理函数签名的代码(请遵循下方的函数规则)
  2. 创建函数:
    node scripts/create-function.js --name <name> --code-file <path>
  3. 部署函数:
    node scripts/deploy-function.js --function-id <id>
  4. 验证部署:
    node scripts/get-function.js --function-id <id>

Set up agent node with app integrations

配置带应用集成的Agent节点

  1. Find model:
    node scripts/list-provider-models.js
  2. Find account:
    node scripts/list-accounts.js --app-slug <slug>
    (use
    pipedream_account_id
    )
  3. Find action:
    node scripts/search-actions.js --query <word> --app-slug <slug>
    (action_id = key)
  4. Create integration:
    node scripts/create-integration.js --action-id <id> --app-slug <slug> --account-id <id> --configured-props <json>
  5. Add tools to agent node via
    flow_agent_app_integration_tools
  1. 查找模型:
    node scripts/list-provider-models.js
  2. 查找账号:
    node scripts/list-accounts.js --app-slug <slug>
    (使用
    pipedream_account_id
  3. 查找操作:
    node scripts/search-actions.js --query <word> --app-slug <slug>
    action_id
    对应返回结果中的
    key
  4. 创建集成:
    node scripts/create-integration.js --action-id <id> --app-slug <slug> --account-id <id> --configured-props <json>
  5. 通过
    flow_agent_app_integration_tools
    为Agent节点添加工具

Database CRUD

数据库增删改查(CRUD)

  1. List tables:
    node scripts/list-tables.js
  2. Query:
    node scripts/query-rows.js --table <name> --filters <json>
  3. Create/update/delete with row scripts
  1. 列出数据表:
    node scripts/list-tables.js
  2. 查询数据:
    node scripts/query-rows.js --table <name> --filters <json>
  3. 使用行操作脚本完成数据的创建、更新与删除

Graph rules

流程图规则

  • Exactly one start node with
    id
    =
    start
  • Never change existing node IDs
  • Use
    {node_type}_{timestamp_ms}
    for new node IDs
  • Non-decide nodes have 0 or 1 outgoing
    next
    edge
  • Decide edge labels must match
    conditions[].label
  • Edge keys are
    source
    /
    target
    /
    label
    (not
    from
    /
    to
    )
For full schema details, see
references/graph-contract.md
.
  • 必须有且仅有一个
    id
    start
    的起始节点
  • 切勿修改现有节点的ID
  • 新节点ID使用
    {node_type}_{timestamp_ms}
    格式
  • 非决策节点的
    next
    输出边数量为0或1
  • 决策节点的边标签必须与
    conditions[].label
    匹配
  • 边的键为
    source
    /
    target
    /
    label
    (而非
    from
    /
    to
完整的Schema详情,请查看
references/graph-contract.md

Function rules

函数规则

js
async function handler(request, env) {
  // Parse input
  const body = await request.json();
  // Use env.KV and env.DB as needed
  return new Response(JSON.stringify({ result: "ok" }));
}
  • Do NOT use
    export
    ,
    export default
    , or arrow functions
  • Return a
    Response
    object
js
async function handler(request, env) {
  // Parse input
  const body = await request.json();
  // Use env.KV and env.DB as needed
  return new Response(JSON.stringify({ result: "ok" }));
}
  • 请勿使用
    export
    export default
    或箭头函数
  • 必须返回
    Response
    对象

Execution context

执行上下文

Always use this structure:
  • vars
    - user-defined variables
  • system
    - system variables
  • context
    - channel data
  • metadata
    - request metadata
请始终遵循以下结构:
  • vars
    - 用户定义变量
  • system
    - 系统变量
  • context
    - 渠道数据
  • metadata
    - 请求元数据

Scripts

脚本说明

Workflows

工作流相关

ScriptPurpose
list-workflows.js
List workflows (metadata only)
get-workflow.js
Get workflow metadata
create-workflow.js
Create a workflow
update-workflow-settings.js
Update workflow settings
脚本用途
list-workflows.js
列出所有工作流(仅返回元数据)
get-workflow.js
获取工作流元数据
create-workflow.js
创建工作流
update-workflow-settings.js
更新工作流设置

Graph

流程图相关

ScriptPurpose
get-graph.js
Get workflow graph + lock_version
edit-graph.js
Patch graph via string replacement
update-graph.js
Replace entire graph
validate-graph.js
Validate graph structure locally
脚本用途
get-graph.js
获取工作流流程图及
lock_version
edit-graph.js
通过字符串替换方式修改流程图
update-graph.js
替换整个工作流流程图
validate-graph.js
本地验证流程图结构合法性

Triggers

触发器相关

ScriptPurpose
list-triggers.js
List triggers for a workflow
create-trigger.js
Create a trigger
update-trigger.js
Enable/disable a trigger
delete-trigger.js
Delete a trigger
list-whatsapp-phone-numbers.js
List phone numbers for trigger setup
脚本用途
list-triggers.js
列出指定工作流的所有触发器
create-trigger.js
创建触发器
update-trigger.js
启用或禁用触发器
delete-trigger.js
删除触发器
list-whatsapp-phone-numbers.js
列出可用于触发器配置的WhatsApp手机号

Executions

执行管理相关

ScriptPurpose
list-executions.js
List executions
get-execution.js
Get execution details
get-context-value.js
Read value from execution context
update-execution-status.js
Force execution state
resume-execution.js
Resume waiting execution
list-execution-events.js
List execution events
脚本用途
list-executions.js
列出执行记录
get-execution.js
获取执行详情
get-context-value.js
读取执行上下文中的变量值
update-execution-status.js
强制修改执行状态
resume-execution.js
恢复处于等待状态的执行流程
list-execution-events.js
列出执行事件记录

Functions

函数相关

ScriptPurpose
list-functions.js
List project functions
get-function.js
Get function details + code
create-function.js
Create a function
update-function.js
Update function code
deploy-function.js
Deploy function to runtime
invoke-function.js
Invoke function with payload
list-function-invocations.js
List function invocations
脚本用途
list-functions.js
列出项目中的所有函数
get-function.js
获取函数详情及代码
create-function.js
创建函数
update-function.js
更新函数代码
deploy-function.js
将函数部署至运行时环境
invoke-function.js
传入负载调用函数
list-function-invocations.js
列出函数调用记录

App integrations

应用集成相关

ScriptPurpose
list-apps.js
Search integration apps
search-actions.js
Search actions (action_id = key)
get-action-schema.js
Get action JSON schema
list-accounts.js
List connected accounts
create-connect-token.js
Create OAuth connect link
configure-prop.js
Resolve remote_options for a prop
reload-props.js
Reload dynamic props
list-integrations.js
List saved integrations
create-integration.js
Create an integration
update-integration.js
Update an integration
delete-integration.js
Delete an integration
脚本用途
list-apps.js
搜索可集成的应用
search-actions.js
搜索应用操作(
action_id
对应返回结果中的
key
get-action-schema.js
获取操作的JSON Schema
list-accounts.js
列出已连接的账号
create-connect-token.js
创建OAuth连接链接
configure-prop.js
解析属性的远程选项
reload-props.js
重新加载动态属性
list-integrations.js
列出已保存的集成配置
create-integration.js
创建集成配置
update-integration.js
更新集成配置
delete-integration.js
删除集成配置

Databases

数据库相关

ScriptPurpose
list-tables.js
List D1 tables
get-table.js
Get table schema + sample rows
query-rows.js
Query rows with filters
create-row.js
Create a row
update-row.js
Update rows
upsert-row.js
Upsert a row
delete-row.js
Delete rows
脚本用途
list-tables.js
列出D1数据表
get-table.js
获取数据表Schema及示例数据行
query-rows.js
带过滤条件查询数据行
create-row.js
创建数据行
update-row.js
更新数据行
upsert-row.js
插入或更新数据行
delete-row.js
删除数据行

OpenAPI

OpenAPI相关

ScriptPurpose
openapi-explore.mjs
Explore OpenAPI (search/op/schema/where)
Install deps (once):
bash
npm i
Examples:
bash
node scripts/openapi-explore.mjs --spec workflows search "variables"
node scripts/openapi-explore.mjs --spec workflows op getWorkflowVariables
node scripts/openapi-explore.mjs --spec platform op queryDatabaseRows
脚本用途
openapi-explore.mjs
探索OpenAPI(搜索、操作、Schema查询等)
安装依赖(仅需执行一次):
bash
npm i
示例:
bash
node scripts/openapi-explore.mjs --spec workflows search "variables"
node scripts/openapi-explore.mjs --spec workflows op getWorkflowVariables
node scripts/openapi-explore.mjs --spec platform op queryDatabaseRows

Notes

注意事项

  • Prefer file paths over inline JSON (
    --definition-file
    ,
    --code-file
    )
  • action_id
    is the same as
    key
    from
    search-actions
  • --account-id
    uses
    pipedream_account_id
    from
    list-accounts
  • Variable CRUD (
    variables-set.js
    ,
    variables-delete.js
    ) is blocked - Platform API doesn't support it
  • Raw SQL execution is not supported via Platform API
  • 优先使用文件路径而非内联JSON(如
    --definition-file
    --code-file
    参数)
  • action_id
    search-actions
    返回结果中的
    key
    一致
  • --account-id
    需使用
    list-accounts
    返回的
    pipedream_account_id
  • 变量增删改查(对应
    variables-set.js
    variables-delete.js
    )功能被禁用——平台API暂不支持该操作
  • 平台API不支持直接执行原生SQL

References

参考文档

Read before editing:
  • references/graph-contract.md - Graph schema, computed vs editable fields, lock_version
  • references/node-types.md - Node types and config shapes
  • references/workflow-overview.md - Execution flow and states
Other references:
  • references/execution-context.md - Context structure and variable substitution
  • references/triggers.md - Trigger types and setup
  • references/app-integrations.md - App integration and variable_definitions
  • references/functions-reference.md - Function management
  • references/functions-payloads.md - Payload shapes for functions
  • references/databases-reference.md - Database operations
编辑前请阅读:
  • references/graph-contract.md - 流程图Schema、计算字段与可编辑字段说明、lock_version机制
  • references/node-types.md - 节点类型与配置格式
  • references/workflow-overview.md - 执行流程与状态说明
其他参考文档:
  • references/execution-context.md - 上下文结构与变量替换规则
  • references/triggers.md - 触发器类型与配置步骤
  • references/app-integrations.md - 应用集成与变量定义
  • references/functions-reference.md - 函数管理指南
  • references/functions-payloads.md - 函数负载格式说明
  • references/databases-reference.md - 数据库操作指南

Assets

资源文件

FileDescription
workflow-linear.json
Minimal linear workflow
workflow-decision.json
Minimal branching workflow
workflow-agent-simple.json
Minimal agent workflow
workflow-customer-support-intake-agent.json
Customer support intake
workflow-interactive-buttons-decide-function.json
Interactive buttons + decide (function)
workflow-interactive-buttons-decide-ai.json
Interactive buttons + decide (AI)
workflow-api-template-wait-agent.json
API trigger + template + agent
function-decide-route-interactive-buttons.json
Function for button routing
agent-app-integration-example.json
Agent node with app integrations
文件说明
workflow-linear.json
极简线性工作流示例
workflow-decision.json
极简分支工作流示例
workflow-agent-simple.json
极简Agent工作流示例
workflow-customer-support-intake-agent.json
客户支持信息收集工作流
workflow-interactive-buttons-decide-function.json
带交互按钮与函数决策的工作流
workflow-interactive-buttons-decide-ai.json
带交互按钮与AI决策的工作流
workflow-api-template-wait-agent.json
API触发器+模板+Agent工作流
function-decide-route-interactive-buttons.json
按钮路由处理函数
agent-app-integration-example.json
带应用集成的Agent节点示例

Related skills

相关技能

  • integrate-whatsapp
    - Onboarding, webhooks, messaging, templates, flows
  • observe-whatsapp
    - Debugging, logs, health checks
<!-- FILEMAP:BEGIN -->
text
[automate-whatsapp file map]|root: .
|.:{package.json,SKILL.md}
|assets:{agent-app-integration-example.json,databases-example.json,function-decide-route-interactive-buttons.json,functions-example.json,workflow-agent-simple.json,workflow-api-template-wait-agent.json,workflow-customer-support-intake-agent.json,workflow-decision.json,workflow-interactive-buttons-decide-ai.json,workflow-interactive-buttons-decide-function.json,workflow-linear.json}
|references:{app-integrations.md,databases-reference.md,execution-context.md,function-contracts.md,functions-payloads.md,functions-reference.md,graph-contract.md,node-types.md,triggers.md,workflow-overview.md,workflow-reference.md}
|scripts:{configure-prop.js,create-connect-token.js,create-function.js,create-integration.js,create-row.js,create-trigger.js,create-workflow.js,delete-integration.js,delete-row.js,delete-trigger.js,deploy-function.js,edit-graph.js,get-action-schema.js,get-context-value.js,get-execution-event.js,get-execution.js,get-function.js,get-graph.js,get-table.js,get-workflow.js,invoke-function.js,list-accounts.js,list-apps.js,list-execution-events.js,list-executions.js,list-function-invocations.js,list-functions.js,list-integrations.js,list-provider-models.js,list-tables.js,list-triggers.js,list-whatsapp-phone-numbers.js,list-workflows.js,openapi-explore.mjs,query-rows.js,reload-props.js,resume-execution.js,search-actions.js,update-execution-status.js,update-function.js,update-graph.js,update-integration.js,update-row.js,update-trigger.js,update-workflow-settings.js,upsert-row.js,validate-graph.js,variables-delete.js,variables-list.js,variables-set.js}
|scripts/lib/databases:{args.js,filters.js,kapso-api.js}
|scripts/lib/functions:{args.js,kapso-api.js}
|scripts/lib/workflows:{args.js,kapso-api.js,result.js}
<!-- FILEMAP:END -->
  • integrate-whatsapp
    - 初始化配置、Webhook、消息发送、模板管理、流程配置
  • observe-whatsapp
    - 调试、日志查看、健康检查
<!-- FILEMAP:BEGIN -->
text
[automate-whatsapp file map]|root: .
|.:{package.json,SKILL.md}
|assets:{agent-app-integration-example.json,databases-example.json,function-decide-route-interactive-buttons.json,functions-example.json,workflow-agent-simple.json,workflow-api-template-wait-agent.json,workflow-customer-support-intake-agent.json,workflow-decision.json,workflow-interactive-buttons-decide-ai.json,workflow-interactive-buttons-decide-function.json,workflow-linear.json}
|references:{app-integrations.md,databases-reference.md,execution-context.md,function-contracts.md,functions-payloads.md,functions-reference.md,graph-contract.md,node-types.md,triggers.md,workflow-overview.md,workflow-reference.md}
|scripts:{configure-prop.js,create-connect-token.js,create-function.js,create-integration.js,create-row.js,create-trigger.js,create-workflow.js,delete-integration.js,delete-row.js,delete-trigger.js,deploy-function.js,edit-graph.js,get-action-schema.js,get-context-value.js,get-execution-event.js,get-execution.js,get-function.js,get-graph.js,get-table.js,get-workflow.js,invoke-function.js,list-accounts.js,list-apps.js,list-execution-events.js,list-executions.js,list-function-invocations.js,list-functions.js,list-integrations.js,list-provider-models.js,list-tables.js,list-triggers.js,list-whatsapp-phone-numbers.js,list-workflows.js,openapi-explore.mjs,query-rows.js,reload-props.js,resume-execution.js,search-actions.js,update-execution-status.js,update-function.js,update-graph.js,update-integration.js,update-row.js,update-trigger.js,update-workflow-settings.js,upsert-row.js,validate-graph.js,variables-delete.js,variables-list.js,variables-set.js}
|scripts/lib/databases:{args.js,filters.js,kapso-api.js}
|scripts/lib/functions:{args.js,kapso-api.js}
|scripts/lib/workflows:{args.js,kapso-api.js,result.js}
<!-- FILEMAP:END -->