{"id":45448691,"url":"https://github.com/leocodeio/whatsapp-agent","last_synced_at":"2026-02-22T04:36:26.276Z","repository":{"id":338572057,"uuid":"1153216330","full_name":"leocodeio/whatsapp-agent","owner":"leocodeio","description":null,"archived":false,"fork":false,"pushed_at":"2026-02-15T07:10:02.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-15T13:32:35.737Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leocodeio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-02-09T03:30:51.000Z","updated_at":"2026-02-15T07:10:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/leocodeio/whatsapp-agent","commit_stats":null,"previous_names":["leocodeio/whatsapp-agent"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/leocodeio/whatsapp-agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leocodeio%2Fwhatsapp-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leocodeio%2Fwhatsapp-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leocodeio%2Fwhatsapp-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leocodeio%2Fwhatsapp-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leocodeio","download_url":"https://codeload.github.com/leocodeio/whatsapp-agent/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leocodeio%2Fwhatsapp-agent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29704836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T03:17:42.375Z","status":"ssl_error","status_checked_at":"2026-02-22T03:17:31.622Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-22T04:36:25.848Z","updated_at":"2026-02-22T04:36:26.263Z","avatar_url":"https://github.com/leocodeio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WhatsApp Agent\n\nA standalone WhatsApp AI agent built with **Bun.js**, designed to run inside **OpenClaw** and leverage OpenCode's native model routing.\n\n## Setup\n\n### Prerequisites\n- [Bun](https://bun.sh) installed\n- [OpenCode](https://opencode.ai) installed and configured\n- OpenRouter API key (free tier works)\n\n### Install\n\n```bash\ncd whatsapp-agent\nbun install\n```\n\n### Configure\n\nCopy `.env.example` to `.env` and set your provider:\n\n```bash\n# Choose your provider\nINFERENCE_PROVIDER=openrouter   # or 'anthropic'\n\n# Set the API key for your chosen provider\nOPENROUTER_API_KEY=sk-or-...    # if using openrouter\nANTHROPIC_API_KEY=sk-ant-...    # if using anthropic\n```\n\n### Run\n\n```bash\n# Production\nbun run start\n\n# Development (auto-reload)\nbun run dev\n```\n\nOn first run, scan the QR code in terminal with WhatsApp to authenticate.\n\n## Architecture\n\n```\nsrc/\n├── core/agent/agents.ts           # AI agent — provider-agnostic, manages conversation history\n├── providers/opencode/\n│   ├── client.ts                   # OpenCode CLI invocation wrapper\n│   └── resolver.ts                 # Model resolver with automatic fallback\n├── integrations/whatsapp/\n│   ├── connection.ts               # Baileys v7 connection, QR auth, reconnection\n│   └── events.ts                   # Message event bridge\n├── config/\n│   ├── env.ts                      # Environment validation\n│   └── settings.ts                 # App constants\n├── utils/\n│   ├── logger.ts                   # Structured logging\n│   └── errors.ts                   # Error handling utilities\n└── main.ts                         # Entry point\n```\n\n## Inference Providers\n\n### Anthropic (direct)\nSet `INFERENCE_PROVIDER=anthropic` with your `ANTHROPIC_API_KEY`.\n- Default model: `claude-sonnet-4-20250514`\n- Uses Anthropic SDK directly — fastest, most reliable\n\n### OpenRouter (via OpenCode)\nSet `INFERENCE_PROVIDER=openrouter` with your `OPENROUTER_API_KEY`.\n- Default model: `openrouter/moonshotai/kimi-k2.5`\n- Fallback: `openrouter/arcee-ai/trinity-large-preview:free` (free)\n- Auto-resolves and falls back if preferred model unavailable\n\n## How It Works\n\n1. WhatsApp message received via Baileys\n2. Event bridge extracts text and routes to agent\n3. Agent maintains conversation history per chat\n4. Agent invokes OpenCode CLI with the resolved model\n5. Response sent back to WhatsApp\n\n## OpenClaw Compatibility\n\nThis project is designed to run inside OpenClaw's environment:\n- Uses `opencode run -m \u003cmodel\u003e` for model invocation (no custom HTTP)\n- Respects OpenClaw's provider abstraction\n- Environment variables managed via OpenClaw's config\n\n## Error Handling\n\n- Retry with exponential backoff (3 attempts)\n- Graceful shutdown on SIGINT/SIGTERM\n- Structured logging at all levels\n- Conversation history limited to 20 messages per chat\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleocodeio%2Fwhatsapp-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleocodeio%2Fwhatsapp-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleocodeio%2Fwhatsapp-agent/lists"}