WhatsApp integration for Agntrick agents
Project description
agntrick-whatsapp
WhatsApp integration for Agntrick agents.
Installation
pip install agntrick-whatsapp
Features
- WhatsApp Channel: Bidirectional communication via personal WhatsApp account
- Router Agent: Routes messages to different specialist modes based on commands
- Audio Transcription: Transcribe voice messages using Groq Whisper API
- Contact Filtering: Privacy-focused with allowed contacts only
- Scheduling: Schedule reminders and agent tasks with natural language time parsing
- Notes: Save and retrieve notes through WhatsApp
Requirements
System Dependencies
The WhatsApp channel uses neonize which requires:
- libmagic: For file type detection
- macOS:
brew install libmagic - Ubuntu/Debian:
sudo apt-get install libmagic1 - Fedora:
sudo dnf install file-devel
- macOS:
Audio Transcription (Optional)
For audio transcription, you need:
-
ffmpeg: For audio format conversion
- macOS:
brew install ffmpeg - Ubuntu/Debian:
sudo apt-get install ffmpeg - Fedora:
sudo dnf install ffmpeg
- macOS:
-
Groq API Key: Set
GROQ_AUDIO_API_KEYorGROQ_API_KEYenvironment variable
Quick Start
1. Install Dependencies
pip install agntrick-whatsapp
2. Create Configuration
Create a whatsapp.yaml configuration file:
model: claude-sonnet-4-6
mcp_servers: ["fetch", "web-forager"]
privacy:
allowed_contact: "+1234567890" # Your phone number
channel:
storage_path: ~/storage/whatsapp
features:
text_messages: true
media_messages: true
group_messages: false
typing_indicators: true
audio_transcriber:
model: whisper-large-v3-turbo
timeout: 60.0
3. Run the WhatsApp Agent
import asyncio
from pathlib import Path
import yaml
from agntrick_whatsapp import WhatsAppChannel, WhatsAppRouterAgent
from agntrick_whatsapp.config import WhatsAppAgentConfig
async def main():
# Load configuration from YAML
config_path = Path(__file__).parent / "whatsapp.yaml"
with open(config_path) as f:
config_dict = yaml.safe_load(f)
config = WhatsAppAgentConfig.model_validate(config_dict)
# Create channel
channel = WhatsAppChannel(
storage_path=config.get_storage_path(),
allowed_contact=config.privacy.allowed_contact,
)
# Create router agent
agent = WhatsAppRouterAgent(
channel=channel,
model_name=config.model,
mcp_servers_override=config.mcp_servers,
audio_transcriber_config=config.audio_transcriber,
)
# Start listening
await agent.start()
asyncio.run(main())
Commands
The router agent supports the following commands:
| Command | Description |
|---|---|
/learn <topic> |
Learning/tutorial mode |
/youtube <url> |
YouTube video analysis |
/remind <time> <message> |
Set a reminder |
/schedule <time> <agent> [task] |
Schedule an agent task |
/schedules |
List all scheduled tasks |
/note <content> |
Save a note |
/notes |
List all saved notes |
/help |
Show available commands |
Examples
/learn Python decorators- Get a step-by-step tutorial on Python decorators/youtube https://youtube.com/watch?v=xyz- Analyze a YouTube video/remind in 30 min check the oven- Set a reminder/schedule tomorrow 9am assistant summarize news- Schedule a task/note Remember to call mom- Save a noteWhat's the weather in Tokyo?- General question
Audio Transcription
Voice messages are automatically transcribed using Groq's Whisper API:
from agntrick_whatsapp import AudioTranscriber
transcriber = AudioTranscriber()
result = await transcriber.transcribe_audio("/path/to/voice.ogg")
print(result)
Configuration Reference
PrivacyConfig
| Field | Type | Required | Description |
|---|---|---|---|
allowed_contact |
str | Yes | Phone number to allow messages from |
log_filtered_messages |
bool | No | Log filtered messages for debugging |
FeatureFlags
| Field | Type | Default | Description |
|---|---|---|---|
text_messages |
bool | true | Enable text messages |
media_messages |
bool | true | Enable media messages |
group_messages |
bool | false | Enable group messages |
presence_updates |
bool | true | Enable presence updates |
typing_indicators |
bool | true | Send typing indicators |
AudioTranscriberConfig
| Field | Type | Default | Description |
|---|---|---|---|
model |
str | whisper-large-v3-turbo | Groq Whisper model |
timeout |
float | 60.0 | Request timeout in seconds |
config_file |
str? | None | Optional config file path |
Development
Setup
# Clone the repository
git clone https://github.com/jeancsil/agntrick-whatsapp.git
cd agntrick-whatsapp
# Install dependencies with uv
uv sync
# Run tests
make test
# Run linting
make check
Release
make release VERSION=0.4.0
Troubleshooting
neonize Import Error
RuntimeError: neonize dependency is unavailable
Install system dependencies (libmagic) and reinstall:
brew install libmagic # macOS
pip install agntrick-whatsapp --force-reinstall
QR Code Not Appearing
- Check storage path permissions
- Delete existing session:
rm -rf ~/storage/whatsapp(take care with this and always ask the user) - Restart the agent
Audio Transcription Fails
- Verify Groq API key:
echo $GROQ_AUDIO_API_KEY - Check ffmpeg:
ffmpeg -version - Check file size (max 25MB)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agntrick_whatsapp-0.3.5.tar.gz.
File metadata
- Download URL: agntrick_whatsapp-0.3.5.tar.gz
- Upload date:
- Size: 270.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8a9996387bc74ce1e5449627e52ab85cbf2456de2360f13524389b398f96358
|
|
| MD5 |
119b5f9ef6c7a5a25ac560d9a971fb33
|
|
| BLAKE2b-256 |
c5318c8eb7a6ee1037de2117c6836c3067e0d102e9e14ab80f91c6f03e259bb8
|
Provenance
The following attestation bundles were made for agntrick_whatsapp-0.3.5.tar.gz:
Publisher:
release.yml on jeancsil/agntrick-whatsapp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agntrick_whatsapp-0.3.5.tar.gz -
Subject digest:
e8a9996387bc74ce1e5449627e52ab85cbf2456de2360f13524389b398f96358 - Sigstore transparency entry: 1102888663
- Sigstore integration time:
-
Permalink:
jeancsil/agntrick-whatsapp@f3cdd33fc64a4ae2d443d9427b3859557116f6c6 -
Branch / Tag:
refs/tags/v0.3.5 - Owner: https://github.com/jeancsil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f3cdd33fc64a4ae2d443d9427b3859557116f6c6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file agntrick_whatsapp-0.3.5-py3-none-any.whl.
File metadata
- Download URL: agntrick_whatsapp-0.3.5-py3-none-any.whl
- Upload date:
- Size: 33.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae427dae7dc73ca4e1b2929e6d02f2a8feafca74e307605bb571efabcd355ad6
|
|
| MD5 |
853e21a244735e67008f089276e5e97b
|
|
| BLAKE2b-256 |
6d25af6b399540ed1866b9c813a5be793e7ac3003321b19c808c6fe372c9950a
|
Provenance
The following attestation bundles were made for agntrick_whatsapp-0.3.5-py3-none-any.whl:
Publisher:
release.yml on jeancsil/agntrick-whatsapp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agntrick_whatsapp-0.3.5-py3-none-any.whl -
Subject digest:
ae427dae7dc73ca4e1b2929e6d02f2a8feafca74e307605bb571efabcd355ad6 - Sigstore transparency entry: 1102888684
- Sigstore integration time:
-
Permalink:
jeancsil/agntrick-whatsapp@f3cdd33fc64a4ae2d443d9427b3859557116f6c6 -
Branch / Tag:
refs/tags/v0.3.5 - Owner: https://github.com/jeancsil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f3cdd33fc64a4ae2d443d9427b3859557116f6c6 -
Trigger Event:
release
-
Statement type: