SparkWA — The Headless WhatsApp to Google Gemini Spark Bridge

SparkWA technical reference

SparkWA routes authorized WhatsApp messages through a self-hosted Go bridge and Gmail to a configured Gemini Spark workflow. This reference documents setup, operation, and security considerations.

Fast 1-Line Installation & Runner UBUNTU / DEBIAN / LINUX
curl -fsSL https://raw.githubusercontent.com/krishujeniya/sparkwa/main/scripts/setup-apt.sh | sudo bash
Automatically installs SparkWA via apt and immediately launches the interactive TUI dashboard. Reopen anytime with sparkwa.
Security boundaries

System Integration Pipeline

SparkWA uses sender validation, task correlation, and scoped OAuth access. Review the security guide and deployment configuration before handling sensitive messages.

NODE [1]

WhatsApp Bot

Dedicated secondary WhatsApp SIM account. Connects headlessly via terminal QR code.

NODE [2]

Authorized User

Your personal WhatsApp number. Only this number is permitted. Strangers are rejected.

NODE [E]

Gmail Bridge

Secure Google Cloud OAuth 2.0 mailbox on VPS that delivers commands to Gemini Spark.

NODE [S]

Gemini Spark

Your autonomous AI agent in Google Workspace with direct access to Docs, Drive & Calendar.

DATA PIPELINE: [2 ➔ 1] Inbound ➔ [1 ➔ E] Bridge Dispatch ➔ [E ➔ S] Spark Process ➔ [S ➔ E] Spark Reply ➔ [E ➔ 2] WhatsApp Delivery

Architectural Message Flow Diagram

End-to-end execution path between your personal WhatsApp and Gemini Spark

NODE [2] [AUTHORIZED SENDER]
Your Personal WhatsApp (Number 2)
The only allowlisted phone number permitted to issue instructions
(1) Send text message or command
▼
NODE [1] [WHATSAPP BOT]
Dedicated WhatsApp Bot (Number 1)
Dedicated SIM connected headlessly via whatsmeow multi-device protocol
(2) Read by SparkWA on your server
▼
NODE [E] [SPARKWA LOCAL ENGINE]
SparkWA Background Service (/var/lib/sparkwa)
Fail-closed authorization, atomic state persistence, and RFC-2822 formatting
  • Verifies sender matches Number 2 (strangers dropped silently)
  • Saves task to local SQLite database (/var/lib/sparkwa/sparkwa.db)
  • Formats email protocol RFC-2822: [SPARKWA:TASK_ID]
  • Sends email via official Google Cloud OAuth 2.0 Gmail API
(3) Outbound email via Gmail API
▼
NODE [S] [GOOGLE WORKSPACE & GEMINI SPARK]
Autonomous Cloud Execution Environment
Bridge Gmail to Spark mailbox trigger with Google Workspace integration
Bridge Gmail Spark Gmail Inbox
(4) Event trigger
▼
Gemini Spark Agent
Runs task using Google tools (Drive, Docs, Sheets, Calendar) with standing approval
(5) Email reply or draft
▼
Bridge Gmail Spark Gmail Outbox
(6) Discovered by SparkWA poller
▼
NODE [2] [DELIVERY TO USER]
Your Personal WhatsApp (Number 2)
Spark's synthesized answer delivered directly to your chat in clean conversational text
24/7 Autonomous Execution

Master Gemini Spark System Prompt

Copy and paste this exact instruction into your Gemini Custom Instructions, Gem instructions, or Scheduled Task. It gives Spark permanent standing authorization so it never pauses to ask "Should I send this email?", never echoes command envelopes, and always delivers the direct answer to your WhatsApp.

GEMINI SPARK MASTER INSTRUCTION
You are an autonomous execution worker integrated with SparkWA. You run 24/7 in the background without requiring manual human supervision.

You receive automated tasks via incoming emails with subjects formatted as:
[SPARKWA:REQUEST_ID] <Short Title>

The email body will follow this format:
BEGIN SPARKWA COMMAND
Request ID: <REQUEST_ID>
Authorized sender: <MASKED_PHONE>
Timestamp: <ISO8601>
Command: <USER_INSTRUCTION>
END SPARKWA COMMAND

OPERATING PROTOCOL:
1. IMMEDIATE AUTONOMOUS EXECUTION (24/7):
   - You have standing, permanent authorization to execute tasks and send reply emails automatically.
   - NEVER ask "Should I send this email?", "Do you want me to reply?", or "Shall I proceed?".
   - NEVER pause or wait for user confirmation to send the email response. Send the email reply directly and immediately to the sender.

2. NEVER ECHO OR QUOTE THE INPUT:
   - NEVER repeat, quote, or echo the "BEGIN SPARKWA COMMAND" block in your reply.
   - Extract only the text after "Command: " and treat it as the real instruction to execute.
   - If the command is a conversational greeting (e.g., "Hi", "Hello"), reply directly and politely.
   - If the command is a query, answer it thoroughly.
   - If the command requires Google Workspace tools (Gmail, Drive, Docs, Sheets, Calendar), use them directly to complete the task.

3. STRICT RESPONSE FORMAT:
   Always reply directly to the email thread using this exact structure:

BEGIN SPARKWA RESPONSE
Request ID: <REQUEST_ID>
Status: SUCCESS
Result: <YOUR DIRECT ANSWER, SUMMARY, OR OUTPUT>
END SPARKWA RESPONSE

   - Replace <REQUEST_ID> with the exact Request ID from the incoming email.
   - Put your actual answer or output after "Result: ".
   - Do not include extra conversational text outside of this block.

4. SAFETY GUARDRAILS (DESTRUCTIVE ACTIONS ONLY):
   - Only if a command asks for an irreversible or high-risk action (such as deleting files, mass-emailing clients, or financial transactions), do NOT execute it immediately.
   - Instead, respond with:

BEGIN SPARKWA RESPONSE
Request ID: <REQUEST_ID>
Status: APPROVAL_REQUIRED
Result: This action requires your confirmation: [brief description]. Reply YES to confirm.
END SPARKWA RESPONSE
Real-Time Control

WhatsApp Slash Commands

Send these commands from your authorized personal WhatsApp number directly to the bot account:

Command Action Expected Response
Latency & responsiveness diagnostic Instant pong reply with server UTC timestamp
System integration & capability audit Live health check for WhatsApp, Gmail, and Gemini Spark
Inspect recent tasks in SQLite queue Compact table of recent task IDs, flows, and states
Inspect details of a specific task Full execution timestamps, Gmail thread ID, and results
Cancel an active pending task Marks the task cancelled and cancels outbound worker dispatch
Quick command cheatsheet Displays the full operational command guide
Real-World Workflows

Example Prompts for Gemini Spark

Any natural language text sent from your authorized personal WhatsApp is delivered directly to Gemini Spark. Spark executes actions using Google Workspace APIs and streams answers back to chat.

CALENDAR Google Calendar API

Schedule Calendar Sync

WhatsApp Prompt

Schedule a 30-minute sync with Alex tomorrow at 3:00 PM and invite alex@company.com

Spark Action: Checks your calendar for schedule collisions, books the event with a Google Meet link, sends calendar invitations, and returns meeting confirmation to WhatsApp.

SCHEDULE Calendar & Tasks

Morning Daily Agenda

WhatsApp Prompt

What meetings and tasks do I have scheduled for today and tomorrow morning?

Spark Action: Aggregates events from Google Calendar and to-dos from Google Tasks, organizes them into a chronological agenda, and delivers it to your chat.

RESCHEDULE Google Calendar API

Reschedule Existing Meeting

WhatsApp Prompt

Move my 2:00 PM team review today to Thursday at 11:00 AM.

Spark Action: Locates the calendar entry, checks attendee availability, updates start/end timestamps, and dispatches automated update notices.

GMAIL Gmail ReadOnly API

Inbox Priority Summary

WhatsApp Prompt

Summarize my unread emails from the past 24 hours. Highlight any urgent emails from clients or management.

Spark Action: Scans incoming messages, filters newsletters and spam, produces bullet summaries for key threads, and flags urgent action items.

DRAFTS Gmail Compose API

Draft Email Reply

WhatsApp Prompt

Draft a polite reply to Sarah's email regarding the product roadmap delay, confirming we will ship on Friday.

Spark Action: Drafts the response directly into your Gmail account, formats it appropriately, and provides a preview back to WhatsApp for your review.

SHEETS Google Sheets API

Append Spreadsheet Row

WhatsApp Prompt

Add a row to the '2026 Expense Log' spreadsheet: Nov 3, Client Lunch, $64.20, Paid via Visa.

Spark Action: Accesses the spreadsheet in Google Drive, maps columns accurately, appends the entry, and reports the updated sheet total.

DRIVE Google Drive API

Search Google Drive Files

WhatsApp Prompt

Find the latest 'Q4 Financial Review' presentation in my Google Drive and summarize key revenue milestones.

Spark Action: Locates the file in Google Drive, analyzes slide text and charts, and produces an executive briefing delivered directly to your chat.

SAFETY Human Confirmation

Destructive Action Safety Guardrail

WhatsApp Prompt

Draft an announcement email to all team leads about Friday server maintenance.

[APPROVAL REQUIRED]
Task: 256c0c48
Action: Send announcement email to team-all@company.com (18 recipients).
Reply with your confirmation or cancellation.

Spark Action: Detects external high-impact action, pauses execution, and demands your confirmation before sending.

Enterprise Hardening

Security & Privacy Architecture

SparkWA is engineered for fail-closed, multi-tenant safety. Your server is completely isolated.

[SHIELD] Strict Allowlist Only

SparkWA enforces strict fail-closed phone authorization. Messages from unauthorized phone numbers, group chats, broadcasts, or bots are dropped immediately with zero execution.

[LOCK] Zero Shell Execution

SparkWA contains zero shell evaluation (no sh -c or exec.Command on user input). All tasks are purely routed via structured Google API requests.

[BOX] Systemd Linux Sandboxing

Runs under strict Linux sandboxing: ProtectSystem=strict, ProtectHome=yes, NoNewPrivileges=yes, and PrivateTmp=yes.

[EYE] Total Privacy Masking

Phone numbers, email addresses, and command contents are scrubbed from TUI screens and daemon logs, preventing unauthorized shoulder-surfing on shared VPS terminals.

Answers

Frequently Asked Questions

Do I need to leave my laptop on?

No. SparkWA runs 24/7 in the background on your Linux VPS (or Raspberry Pi). Your laptop can be closed or turned off.

Does SparkWA require Docker, Node.js, Python, or Chromium?

No. SparkWA is written in pure Go and compiled into a single static binary. It has zero external software dependencies.

How much RAM does it need?

SparkWA uses approximately 28 MB to 35 MB of RAM at idle. It runs reliably on the smallest 512 MB or 1 GB VPS instances.

What happens if my VPS reboots?

The systemd service unit automatically starts SparkWA on boot, reconnects WhatsApp and Gmail, and recovers any pending tasks from the embedded SQLite database.

Copied to clipboard