You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document defines the functional and non-functional requirements for OpenWA.
2.2 Functional Requirements
2.2.1 Session Management
flowchart LR
subgraph Session["Session Lifecycle"]
C[Create] --> A[Authenticate]
A --> |QR Scan| R[Ready]
R --> |Logout| D[Destroy]
R --> |Disconnect| RC[Reconnect]
RC --> R
end
Loading
ID
Requirement
Priority
Phase
FR-SM-001
The system must create new sessions
High
1
FR-SM-002
The system must generate a QR code for authentication
High
1
FR-SM-003
The system must persist session state for reconnection
High
1
FR-SM-004
The system must delete a session
High
1
FR-SM-005
The system must display session status
High
1
FR-SM-006
The system must support multiple sessions
High
2
FR-SM-007
The system must auto-reconnect when the connection is lost
Medium
2
FR-SM-008
The system must support session naming
Low
2
2.2.2 Messaging
flowchart TB
subgraph Outbound["Outbound Messages"]
T[Text]
I[Image]
V[Video]
A[Audio]
D[Document]
L[Location]
CT[Contact]
S[Sticker]
end
subgraph Inbound["Inbound Messages"]
W[Webhook] --> P[Process]
P --> ACK[Acknowledgment]
end
Outbound --> API[REST API]
API --> WA[WhatsApp]
WA --> Inbound
Loading
ID
Requirement
Priority
Phase
FR-MSG-001
The system must send text messages
High
1
FR-MSG-002
The system must send images with captions
High
1
FR-MSG-003
The system must send video messages
High
1
FR-MSG-004
The system must send audio/voice notes
High
1
FR-MSG-005
The system must send documents/files
High
1
FR-MSG-006
The system must send locations
Medium
2
FR-MSG-007
The system must send contact cards
Medium
2
FR-MSG-008
The system must send stickers
Medium
2
FR-MSG-009
The system must reply to a message
Medium
2
FR-MSG-010
The system must forward messages
Low
3
FR-MSG-011
The system must delete messages
Low
3
FR-MSG-012
The system must react to messages
Low
3
FR-MSG-013
The system must send bulk messages (batch)
Medium
2
FR-MSG-014
The system must support template variables in bulk messages
Medium
2
FR-MSG-015
The system must track status per message in a batch
Medium
2
FR-MSG-016
The system must cancel a running batch
Medium
2
FR-MSG-017
The system must apply delays between messages to reduce ban risk
High
2
FR-MSG-018
The system must validate media size before sending
High
1
FR-MSG-019
The system must support downloading media from a URL
High
1
2.2.3 Webhook & Events
sequenceDiagram
participant WA as WhatsApp
participant OW as OpenWA
participant WH as Webhook URL
WA->>OW: New Message Event
OW->>OW: Process & Store
OW->>WH: POST /webhook
WH-->>OW: 200 OK
alt Webhook Failed
OW->>OW: Queue for Retry
OW->>WH: Retry (max 3x)
end
Loading
ID
Requirement
Priority
Phase
FR-WH-001
The system must deliver events to webhook URLs
High
1
FR-WH-002
The system must support multiple webhook URLs
Medium
2
FR-WH-003
The system must retry failed webhooks (max 3x)
Medium
2
FR-WH-004
The system must filter event types per webhook
Medium
2
FR-WH-005
The system must log webhook delivery status
Medium
2
FR-WH-006
The system must support webhook signature verification
Medium
2
FR-WH-007
The system must provide an idempotency key per event
High
2
FR-WH-008
The system must provide a delivery ID to track retries
Medium
2
FR-WH-009
The system must support exponential backoff for retries
Medium
2
FR-WH-010
The system must enable/disable webhooks without deletion
Low
2
2.2.4 Real-time Updates (WebSocket)
flowchart LR
subgraph WebSocket["WebSocket Features"]
direction TB
CONN[Connection Management]
AUTH[Authentication]
SUB[Event Subscription]
PING[Keep-alive Ping/Pong]
end
subgraph Events["Real-time Events"]
MSG[Message Events]
SESS[Session Events]
QR[QR Code Updates]
end
WebSocket --> Events
Loading
ID
Requirement
Priority
Phase
FR-WS-001
The system must provide a WebSocket endpoint for real-time updates
Medium
2
FR-WS-002
The system must support API key authentication for WebSocket
Medium
2
FR-WS-003
The system must allow subscribing to a specific session
Medium
2
FR-WS-004
The system must allow subscribing to specific event types
Medium
2
FR-WS-005
The system must implement ping/pong keep-alive
Medium
2
FR-WS-006
The system must auto-reconnect with exponential backoff
Low
3
FR-WS-007
The system must stream QR code updates in real time
High
2
2.2.5 Contact Management
ID
Requirement
Priority
Phase
FR-CT-001
The system must retrieve all contacts
High
1
FR-CT-002
The system must retrieve a contact by ID
High
1
FR-CT-003
The system must check if a number exists on WhatsApp
High
1
FR-CT-004
The system must retrieve a contact profile picture
Medium
2
FR-CT-005
The system must block/unblock a contact
Low
3
2.2.6 Group Management
flowchart TB
subgraph GroupOps["Group Operations"]
direction TB
CR[Create Group]
UP[Update Info]
AD[Add Participants]
RM[Remove Participants]
PR[Promote to Admin]
DM[Demote Admin]
LV[Leave Group]
end
subgraph GroupInfo["Group Info"]
GI[Get Info]
GP[Get Participants]
GL[Get Invite Link]
end
Loading
ID
Requirement
Priority
Phase
FR-GR-001
The system must retrieve all groups
Medium
2
FR-GR-002
The system must retrieve group info
Medium
2
FR-GR-003
The system must retrieve group participants
Medium
2
FR-GR-004
The system must create a group
Medium
3
FR-GR-005
The system must update group info
Low
3
FR-GR-006
The system must add participants
Low
3
FR-GR-007
The system must remove participants
Low
3
FR-GR-008
The system must promote/demote admins
Low
3
FR-GR-009
The system must get/revoke invite links
Low
3
FR-GR-010
The system must leave a group
Low
3
2.2.7 Dashboard (Web UI)
flowchart LR
subgraph Dashboard["Dashboard Features"]
direction TB
SS[Session Status]
QR[QR Display]
WM[Webhook Manager]
LG[Logs Viewer]
ST[Statistics]
end
Dashboard --> API[REST API]
API --> BE[Backend]
Loading
ID
Requirement
Priority
Phase
FR-UI-001
The dashboard must display the status of all sessions
sequenceDiagram
actor User
participant API as OpenWA API
participant Engine as WA Engine
participant WA as WhatsApp
User->>API: POST /api/sessions/:sessionId/messages/send-text
API->>API: Validate request
API->>Engine: sendMessage(chatId, text)
Engine->>WA: Send via WhatsApp Web
WA-->>Engine: Message sent
Engine-->>API: Success response
API-->>User: 200 OK {messageId}
Loading
Actors: External application, Developer Precondition: Session is active and connected Main Flow:
User sends a POST request with chatId and text
The system validates the request
The system sends the message via the WhatsApp engine
The system returns the messageId
Alternative Flow:
Session not active → Return 400 error
Invalid phone number → Return 400 error
WhatsApp error → Return 500 error
UC-002: Receive Message via Webhook
sequenceDiagram
participant WA as WhatsApp
participant Engine as WA Engine
participant API as OpenWA
participant WH as User Webhook
WA->>Engine: New message received
Engine->>API: Message event
API->>API: Store message
API->>WH: POST webhook payload
WH-->>API: 200 OK
API->>API: Mark delivered
The API stores the message and sends it to the webhook
The webhook endpoint acknowledges
Alternative Flow:
Webhook failed → Retry 3x
All retries failed → Log and mark failed
UC-003: Create New Session
stateDiagram-v2
[*] --> Creating: POST /sessions
Creating --> WaitingQR: Generate QR
WaitingQR --> Scanning: User scans QR
WaitingQR --> Timeout: 60s timeout
Scanning --> Authenticating: QR scanned
Authenticating --> Ready: Auth success
Authenticating --> Failed: Auth failed
Ready --> [*]
Timeout --> [*]
Failed --> [*]
Loading
2.5 Requirements Traceability Matrix
Requirement ID
Use Case
Test Case
Status
FR-SM-001
UC-003
TC-SM-001
✅ Implemented
FR-SM-002
UC-003
TC-SM-002
✅ Implemented
FR-MSG-001
UC-001
TC-MSG-001
✅ Implemented
FR-WH-001
UC-002
TC-WH-001
✅ Implemented
2.6 Acceptance Criteria
Phase 1 MVP Acceptance Criteria
✓ A single session can be created and authenticated
✓ QR code can be scanned and session connected
✓ Text messages can be sent
✓ Image messages can be sent
✓ Incoming messages are forwarded to webhooks
✓ API documentation is available via Swagger
✓ Docker image can be built and run
✓ Basic health check endpoint works
Phase 2 Acceptance Criteria
✓ Multiple sessions can run concurrently
✓ Dashboard can display all sessions
✓ Webhooks can be managed via UI
✓ PostgreSQL can be used as storage
✓ API key authentication works
✓ Rate limiting is enabled