viola-agent
A self-hosted WhatsApp AI agent. A company deploys one copy, fills in its own Twilio, LLM (OpenRouter or UniAPI) and optional billing credentials, and gets an assistant its customers and staff can message on WhatsApp.
→ Setup guide: docs/getting-started.md covers what goes in
.env, starting it with Docker Compose, connecting Twilio, and customising the agent.
cp .env.example .env # fill in Twilio + LLM (see the guide)
docker compose up -d # image: ghcr.io/virpluzteam/viola-agent
Releases are published as a Docker image (ghcr.io/virpluzteam/viola-agent, amd64 and
arm64) and as a pip package (pip install 'viola-agent[twilio]'). Both are built from
the same wheel and read the same .env.
Status: being generalised from an internal project. See PLAN.md for the roadmap.
Layout
viola/— agent package.viola serveruns everything on one port: the Twilio WhatsApp webhook, an OpenAI-compatible API and/healthtests/— pytest suite
Run locally
python3.13 -m venv .venv && .venv/bin/pip install -e ".[twilio]" --group dev # pip >= 25.1; or: uv sync --all-extras
cp .env.example .env # fill in Twilio, LLM and (optionally) billing values,
# and set APP_ENV=development to run without Redis
.venv/bin/viola serve --port 8900
viola serve reads .env from the current directory (or $VIOLA_ENV_FILE) and stores
its data — config.json, the workspace with chat history, media, the billing outbox,
viola.db (notification idempotency), content_sid_map.json — in
$VIOLA_DATA_DIR (default ~/.viola). Without REDIS_URL it uses in-memory dedup and rate
limits, which is fine for one local process; APP_ENV=production requires Redis.
Twilio must reach the webhook over public HTTPS. For a server, see
Expose it over HTTPS (bundled Caddy profile
or a Cloudflare Tunnel; both publish only /twilio/*). For development, run ngrok http 8900,
set PUBLIC_BASE_URL=https://<ngrok-host> in .env, and set Twilio's "A message comes in"
URL to https://<ngrok-host>/twilio/webhook. Requests whose X-Twilio-Signature does not
match PUBLIC_BASE_URL + path are rejected with 403.
Routes:
POST /twilio/webhook— Twilio inbound; verifies the signature, ignores repeatedMessageSids, rate-limits per sender, replies202and answers in the backgroundGET /twilio/webhook— plain-text probePOST /twilio/status— optional Twilio status callback (acknowledged)POST /v1/chat/completions— OpenAI-compatible API for the portal backend: needs the server key and auserin the body; the session isportal:<user>:<session_id>POST /v1/notify— send a proactive WhatsApp message (see below)
Every /v1/* route needs Authorization: Bearer $VIOLA_API_SERVER_KEY (401 otherwise) and
returns 404 when no server key is configured.
Tools are off by default. Each channel profile (whatsapp, portal) gets only the tools
listed for it in config.json → profiles; see docs/phase5-channels.md.
GET /health— JSON health
Proactive messages and templates
WhatsApp lets a business send free text only within 24 hours of the customer's last
message; outside that window only Meta-approved templates may be sent. Every inbound
message opens the window (stored in Redis, or memory in development). /v1/notify, cron
reminders and heartbeat all go through viola.notify.send:
- window open and
fallback_textgiven → the text is sent - otherwise an approved
template_id→ the template is sent - otherwise nothing is sent:
422 template_requiredwith the reason (a rule, not a failure)
curl -X POST https://<host>/v1/notify \
-H "Authorization: Bearer $VIOLA_API_SERVER_KEY" -H "Content-Type: application/json" \
-d '{"to": "+85212345678", "template_id": "reminder",
"variables": {"reminder_text": "your appointment is tomorrow at 10:00"},
"fallback_text": "Hi! Your appointment is tomorrow at 10:00.",
"idempotency_key": "appt-123-reminder"}'
Responses: 200 sent (mode is text or template), 422 template_required,
502 twilio_error, 409 same idempotency_key with a different body (or still sending),
400 bad request or missing idempotency_key, 401 bad server key. A repeated
idempotency_key never sends twice: it returns the first result (kept for 7 days in
$VIOLA_DATA_DIR/viola.db). A key whose send failed may be retried.
Templates live in viola/notify/templates.yaml (welcome, reminder, follow-up, generic
notification; en and zh_HK). To use your own, copy it to
$VIOLA_DATA_DIR/templates.yaml and edit it. Then create them in your Twilio account:
viola templates sync # create in Twilio + submit to Meta (--dry-run, --no-submit, --only)
viola templates status # refresh approval status (approved / pending / rejected)
ContentSids and approval statuses are kept in $VIOLA_DATA_DIR/content_sid_map.json;
only approved templates are used. Cron reminders outside the window use the reminder
template.
Development
.venv/bin/ruff check viola/
.venv/bin/pytest
CI (.github/workflows/ci.yml) runs ruff, pytest (Python 3.11–3.13, Linux and Windows),
a gitleaks scan of the full history (false positives go in .gitleaksignore), a wheel
build and an image build with a smoke test (.github/scripts/smoke-image.sh).
Releasing
-
Set
versioninpyproject.toml(e.g.0.2.1) and merge tomain. -
Tag that commit and push the tag:
git tag v0.2.1 && git push origin v0.2.1
.github/workflows/release.yml checks the tag matches the version, runs CI, then
publishes the wheel and sdist to PyPI, pushes the image to GHCR as 0.2.1, 0.2 and
latest, and creates a GitHub release. One-time setup is described at the top of that
file (PyPI trusted publisher, the pypi environment, making the GHCR package public).
License
MIT — see LICENSE.
Metadata
Release files for viola-agent 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| viola_agent-0.2.1.tar.gz | 349.4 kB | With provenance | Details for viola_agent-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| viola_agent-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for viola_agent-0.2.1-py3-none-any.whl |
Total release size: 770.4 kB
Release files / viola_agent-0.2.1.tar.gz
| Download URL | viola_agent-0.2.1.tar.gz |
|---|---|
| Size | 349.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98cbc7f23c0b3934a7f2477cd6b66232319ec4d781f0bc7304b5ad41e2350e66
|
|
BLAKE2b-256 checksum How to use checksums |
27f5331bc9b0325fa98d54723f01986d2200ffb306bf6fc738c2081db2019a1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / viola_agent-0.2.1-py3-none-any.whl
| Download URL | viola_agent-0.2.1-py3-none-any.whl |
|---|---|
| Size | 421.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
710c0d77eb9b97ac035716d1df9778682686692090754f281442d236fb2462ef
|
|
BLAKE2b-256 checksum How to use checksums |
e2b14599c63ab01176b0f5409ee1e248e5cd180f80bc3278a74acaca86f757ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logSecurity for viola-agent 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for viola_agent-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.