← Catalog

pi-kapso-whatsapp

Pi extension for WhatsApp via Kapso AI — contacts access control with SQLite

Extension

Install

Install with PiG

pig install npm:pi-kapso-whatsapp

Install with Pi

pi install npm:pi-kapso-whatsapp
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "image": "https://raw.githubusercontent.com/serlismaldonado/pi-kapso-whatsapp/main/docs/screenshot.png",
  "skills": [
    "./skills"
  ],
  "extensions": [
    "./index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 1.0.2 (README.md). PiG does not review it.

pi-kapso-whatsapp

Pi coding agent extension for WhatsApp via Kapso AI.
Gives Pi a full set of WhatsApp tools: send messages, manage contacts, control the webhook service, set up Cloudflare tunnels, and handle incoming messages with access control.

ko-fi


Installation

pi install pi-kapso-whatsapp

Or manually:

cd ~/.pi/agent/extensions
git clone https://github.com/serlismaldonado/pi-kapso-whatsapp

Then reload Pi's extensions.


Initial setup

Once installed, tell Pi:

"Set up the WhatsApp bot"

Pi will run the full autonomous setup — no questions, no manual steps:

  1. Checks system requirements (PM2, pi-whatsapp-service, .env)
  2. Installs PM2 if missing
  3. Builds and starts the service
  4. Sets up a Cloudflare tunnel (temporary or custom domain)
  5. Registers the webhook in Kapso
  6. Adds you to the contact allowlist
  7. Verifies everything is running

The only step that may require you is pm2 startup (requires sudo once).


Commands

CommandDescription
/kapso-setupSet API key and phone number ID
/kapso-contactsList contacts with notes
/kapso-instructionsShow paths to SYSTEM.md and PROMPT.md

Tools reference

Receiving messages

ToolDescription
whatsapp_receiveProcess an incoming webhook payload — checks access, loads history, reads SYSTEM.md / PROMPT.md
whatsapp_historyGet conversation history for a contact
whatsapp_log_outLog an outgoing message to the session history
whatsapp_session_endEnd the active session for a contact
whatsapp_statusCheck current processing status

Sending messages

ToolDescription
whatsapp_sendSend a text message
whatsapp_send_imageSend an image (URL or media_id)
whatsapp_send_documentSend a document/file (URL or media_id)
whatsapp_send_audioSend audio or a voice note (voice: true for transcription)
whatsapp_send_videoSend a video with optional caption
whatsapp_send_stickerSend a sticker (WEBP format)
whatsapp_send_reactionReact to a message with an emoji
whatsapp_send_contactSend a contact card (vCard)
whatsapp_send_locationSend a location pin
whatsapp_send_buttonsInteractive message with up to 3 quick-reply buttons
whatsapp_send_listInteractive list menu (up to 10 sections)
whatsapp_send_ctaMessage with a call-to-action URL button
whatsapp_upload_mediaUpload a local file and get a media_id

Templates

ToolDescription
whatsapp_templates_listList approved message templates
whatsapp_send_templateSend a template (works outside the 24h conversation window)

Contact management

ToolDescription
whatsapp_contacts_listList all contacts and their access status
whatsapp_contact_addAdd a contact to the allowlist
whatsapp_contact_removeRemove a contact
whatsapp_contact_updateUpdate name, notes, or enabled status
whatsapp_check_accessCheck if a phone number has access

Webhooks

ToolDescription
whatsapp_webhook_setupRegister a new Kapso webhook
whatsapp_webhooks_listList all registered webhooks
whatsapp_webhook_registerRegister or update the active webhook URL
whatsapp_numbers_listList connected WhatsApp numbers (to get phone_number_id)

Service management

ToolDescription
whatsapp_setup_checkInspect all system requirements and current state
whatsapp_service_statusCheck if the service is running
whatsapp_service_startBuild and start the service with PM2
whatsapp_service_stopStop the service
whatsapp_service_restartRestart the service
whatsapp_service_logsView recent logs
whatsapp_service_configureWrite the .env file
whatsapp_service_setup_autostartConfigure PM2 to start on login
whatsapp_tunnel_setupStart a Cloudflare tunnel and register the webhook URL

Customizing the bot

Identity and behavior

Edit these two files to define who the agent is and how it responds:

  • ~/.pi/agent/extensions/pi-kapso-whatsapp/SYSTEM.md — agent name, personality, scope
  • ~/.pi/agent/extensions/pi-kapso-whatsapp/PROMPT.md — step-by-step response instructions

Changes take effect immediately — no restart needed.

Example: tell Pi:

"Edit SYSTEM.md and PROMPT.md. The agent is called Javi, responds in Spanish with a professional but direct tone, and only handles questions about my services."

Access control

Only contacts in the allowlist receive responses. Others are silently ignored.

whatsapp_contact_add    with {"name": "Ana", "phone_number": "+50488887777"}
whatsapp_contact_update with {"phone_number": "+50488887777", "enabled": false}
whatsapp_contacts_list

Incoming message flow

Kapso webhook → whatsapp_receive
  → ACCESS DENIED  → silent ignore
  → ACCESS GRANTED →
      read contact data + notes
      read session history
      read SYSTEM.md + PROMPT.md
      → Pi processes and replies →
          whatsapp_send (or send_image, send_document, etc.)
          whatsapp_log_out

Sending files

To send a local file:

1. whatsapp_upload_media with {"file_path": "/path/to/file.pdf"}
   → returns media_id

2. whatsapp_send_document with {"to": "+504...", "media_id": "<id>", "filename": "file.pdf"}

MIME type is auto-detected from the file extension.


Tunnel modes

Quick tunnel (no account, URL changes on restart):

whatsapp_tunnel_setup with {"port": 4721}

Uses trycloudflare.com. The webhook in Kapso is updated automatically on each restart.

Permanent tunnel (Cloudflare account + custom domain):

whatsapp_tunnel_setup with {"port": 4721, "customDomain": "whatsapp.yourdomain.com"}

Requires a DNS CNAME in Cloudflare pointing to your named tunnel UUID.


PackageDescription
pi-whatsapp-serviceThe always-on webhook receiver service
pi-monoPi coding agent SDK

License

MIT