Project 04
Chatbot
A customer-service chatbot that runs scripted conversation flows across several channels and opens the right support ticket at the end.
- Status
- In production
- Role
- Sole developer of the backend, the management panel and the QA tool.
- Source
- Private codebase
- Chat webhook
- Flow engine
- Bot messages
- Helpdesk ticket
Problem
The chat platform’s native bots were hard to change and almost impossible to test, and an earlier proof of concept had grown into one long chain of if/elif branches that nobody wanted to touch.
Solution
A TypeScript service that receives chat webhooks and runs each conversation through a declarative flow graph. The engine is a pure function: it takes the graph, the current state and the customer’s input and returns the new state plus a list of actions, with no I/O. A separate executor sends messages, opens categorized helpdesk tickets and closes conversations. One process serves several flows on the same engine.
Engineering highlights
- Nearly 11,000 conversations handled in its first 16 days in production.
- Conversation flows as data: menus and quick replies defined as graph nodes and validated at startup, so a broken flow never goes live.
- Conversation state lives in PostgreSQL, one row per conversation locked with SELECT ... FOR UPDATE, so messages from the same customer are handled in order.
- Webhook intake verifies a signature or token, validates the payload with Zod, answers 200 immediately and drops duplicate events by request id.
- Outgoing calls retry on 429, 5xx and network errors, respect Retry-After and use a timeout per attempt.
- Golden-file tests compare every bot message with the specification documents in both directions. The suite has close to a thousand test cases.
- Analytics record the path each conversation took without storing anything the customer typed.