You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
Markdown
49 lines
1.5 KiB
Markdown
# Task WhatsApp Chatbot
|
|
|
|
## Future Steps
|
|
|
|
### Core Principles
|
|
1. **Trust-but-Verify Approach**: Leverage WhatsApp's message metadata to minimize API calls while maintaining security
|
|
2. **Progressive Validation**: Verify users naturally through interactions rather than upfront checks
|
|
3. **Background Reconciliation**: Use periodic syncs to maintain data accuracy without impacting real-time performance
|
|
|
|
### Message Processing Flow
|
|
```mermaid
|
|
graph TD
|
|
A[Webhook Received] --> B{Valid Payload?}
|
|
B -->|No| C[Ignore]
|
|
B -->|Yes| D{From Known Group?}
|
|
D -->|Yes| E[Update User Last Seen]
|
|
D -->|No| F{Private Chat + Known User?}
|
|
F -->|No| C
|
|
F -->|Yes| E
|
|
E --> G{/tarea Command?}
|
|
G -->|No| C
|
|
G -->|Yes| H{New User?}
|
|
H -->|Yes| I[Add to DB]
|
|
H -->|No| J[Process Command]
|
|
```
|
|
|
|
### Alias for actions
|
|
|
|
- I want that, when an user sends `/tarea` to the bot, with no extra arguments, it should show all the pending tasks for the user in a private message (the same behaviour as calling `/tarea mostrar`
|
|
|
|
### Periodic Sync Strategy
|
|
1. **Rotating Group Check**:
|
|
- Verify 1-2 groups per sync cycle
|
|
- Prioritize recently active groups
|
|
2. **User Reconciliation**:
|
|
- Add newly discovered users
|
|
- Update `last_confirmed` for active users
|
|
3. **Optimizations**:
|
|
- Cache active group IDs in memory
|
|
- Batch database writes
|
|
- Exponential backoff for API failures
|
|
|
|
### Security Considerations
|
|
- Reject messages from:
|
|
- Non-community groups
|
|
- Unknown private chats
|
|
- Implement rate limiting
|
|
- Maintain audit logs of verification events
|