A production-ready WhatsApp automation system for Mosop Farm Inputs. Built with FastAPI and Evolution API, it connects WhatsApp messaging with live Google Sheets inventory data and Vertex AI, with PostgreSQL-backed session persistence and automated deployment through Render.
# Mosop Farm Inputs WhatsApp Bot
This project is a complete deployment architecture for a WhatsApp automation bot for Mosop Farm Inputs. It uses a Python FastAPI backend and the open-source Evolution API, fully orchestrated for deployment on Render.com.
## Architecture & Stack
1. **PostgreSQL Database:** Managed by Render, used exclusively by Evolution API to persist instance sessions so your WhatsApp QR code does not reset on container restarts.
2. **Evolution API Gateway:** A Dockerized web service (`atendai/evolution-api:latest`) configured to use the PostgreSQL DB. Redis is disabled to simplify the stack.
3. **Python FastAPI Backend:** Handles incoming webhooks, filters out bot messages (`fromMe: true`), queries Google Sheets for inventory using `gspread`, and replies to customers.
---
## 🚀 Deployment to Render.com
1. **Push to GitHub**
Commit all the files in this project (`render.yaml`, `main.py`, `requirements.txt`, `README.md`) and push them to a new GitHub repository.
2. **Deploy via Render Blueprint**
* Go to your Render Dashboard.
* Click **New** -> **Blueprint**.
* Connect the GitHub repository you just created.
* Render will automatically detect the `render.yaml` file and deploy the Database, the Evolution API, and the FastAPI backend.
* Click **Apply** and wait for all services to become live.
3. **Link the Services Together**
* Once the **evolution-api** service is live, copy its public URL (e.g., `
evolution-api-xxxx.onrender…`).
* Go to your **mosop-farm-backend** service in the Render dashboard.
* Under the **Environment** tab, update the `EVOLUTION_API_URL` variable with the URL you copied.
* Wait for the backend service to redeploy with the new environment variable.
4. **Set Webhooks on Evolution API**
Configure Evolution API to forward WhatsApp messages to your backend. The webhook endpoint will be:
`
mosop-farm-backend- .
onrender.com`
(You can set this globally in Evolution API env vars or per-instanc …