A lightweight Python-based relay that connects Green-API WhatsApp messages to dynamic n8n webhook URLs based on chat IDs.
Features:
✅ Built on whatsapp_chatbot_python for seamless Green-API integration.
✅ YAML-based configuration with live reload support
✅ Routes messages to different n8n webhooks based on chatId
✅ Async forwarding using httpx
✅ Deployable via Docker Compose or systemd
✅ Structured logging with loguru
The app/config.yaml file defines your Green-API credentials and routing rules:
green_api:
instance_id: "your-instance-id"
token: "your-api-token"
routes:
[email protected]: "https://n8n.local/webhook/route1"
[email protected]: "https://n8n.local/webhook/route2"
🛡️ On first run, the app will auto-create this file if it doesn't exist.
Create the following docker-compose.yaml file:
services:
greenapi-n8n-router:
image: techblog/greenapi-n8n-router
container_name: greenapi-n8n-router
volumes:
- ./app/config/:/app/config
restart: unless-stopped
Run the container using Docker Compose:
docker-compose up -d
Verify the logs:
docker logs -f greenapi-n8n-router
clone the repo:
git clone https://github.com/t0mer/greenapi-n8n-router
Then enter the application folder:
cd greenapi-n8n-router
and run pip command to install the dependencies
pip3 install -r requirements.txt
Create a systemd service file:
sudo nano /etc/systemd/system/greenapi-n8n-router.service
Add the following content:
[Unit]
Description=GreenAPI to n8n Router
After=network.target
[Service]
Type=simple
WorkingDirectory=/path/to/greenapi-n8n-router
ExecStart=/usr/bin/python3 app/main.py
Restart=on-failure
User=your-username
[Install]
WantedBy=multi-user.target
Replace /path/to/greenapi-n8n-router with the actual path to your project directory.
Reload systemd and start the service:
sudo systemctl daemon-reload
sudo systemctl enable greenapi-n8n-router
sudo systemctl start greenapi-n8n-router
Check the service status:
sudo systemctl status greenapi-n8n-router
🧰 Testing
Set your Green-API webhook URL to point to this service. Send a WhatsApp message from a number listed in your config.yaml routes. Verify that the message is forwarded to the corresponding n8n webhook URL.
Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.
Content type
Image
Digest
sha256:996272e35…
Size
64.4 MB
Last updated
4 months ago
docker pull techblog/greenapi-n8n-router