https://github.com/meyer1994/wa
Simple WhatsApp + OpenAI on AWS Lambda
https://github.com/meyer1994/wa
Last synced: 19 days ago
JSON representation
Simple WhatsApp + OpenAI on AWS Lambda
- Host: GitHub
- URL: https://github.com/meyer1994/wa
- Owner: meyer1994
- Created: 2025-03-20T01:01:14.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-26T13:34:04.000Z (about 1 year ago)
- Last Synced: 2025-04-26T14:35:07.595Z (about 1 year ago)
- Language: Python
- Size: 382 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WhatsApp Bot
Simple WhatsApp bot infrastructure on AWS Lambda using CDK.
## Setup
```bash
uv sync
```
To start developing locally:
```bash
docker compose up
```
Create the tables:
- `EVENTS_TABLE`
- `MESSAGES_TABLE`
```bash
make tables
```
Create the RAG bucket:
```bash
make bucket
```
Run the app:
```bash
uv run uvicorn handler:app --reload
```
### Docker
If you don't want to read:
```bash
docker compose up --build
```
## Deployment
Deploy:
```bash
npx aws-cdk deploy --app 'uv run infra.py' --verbose
# or
make deploy
```
Destroy:
```bash
npx aws-cdk destroy --app 'uv run infra.py' --verbose
# or
make destroy
```
Redeploy:
```bash
npx aws-cdk destroy --app 'uv run infra.py' --verbose
# or
make reset
```
## Infrastructure
### Architecture Diagram
Architecture diagram of the infrastructure:
```mermaid
graph TD
User --[send message]--> WhatsApp
WhatsApp --[wbehooks]--> ApiGateway
ApiGateway --> Lambda
Lambda --[store chat messages]--> MessageTable
Lambda --[store raw events]--> EventTable
Lambda --[send message]--> WhatsApp
```
Sequence diagram of the message flow:
```mermaid
sequenceDiagram
User->>WhatsApp: send message
WhatsApp->>ApiGateway: POST /
ApiGateway->>Lambda: proxy
Lambda->>EventTable: store raw event
Lambda->>OpenAI: generate response
OpenAI->>Lambda: response
Lambda->>MessageTable: store chat message
Lambda->>WhatsApp: send message
WhatsApp->>User: message sent
```