QUESTION_ROUTING_GUIDE
Chat Message → Question → Inbox Routing Guide
Overview
This guide shows how to set up a workflow that:
- Listens for customer messages via the chat widget
- Asks the customer a follow-up question
- Routes the conversation to different inboxes based on their answer
Real Inbox IDs
- <strong>Billing:</strong> <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">0zCg6Hso9i1MW38hHCA7</code>
- <strong>Technical Support:</strong> <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">TF7K19mYx9cg3xFrCevu</code>
Workflow Setup
Step 1: Create Workflow Structure
Create a workflow with these nodes in sequence:
Step 2: Configure ask_question Node
<strong>What this does:</strong>
- Shows a question to the customer in the widget
- Pauses the workflow waiting for their response
- Stores their answer in <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">issue_category</code> variable
Step 3: Configure Condition Node
<strong>What this does:</strong>
- Checks if the answer contains "2"
- If yes (contains "2") → goes to <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">route-billing</code>
- If no (doesn't contain "2") → goes to <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">route-tech</code>
Step 4: Configure Route Nodes
<strong>Route to Billing:</strong>
<strong>Route to Technical Support:</strong>
Testing the Workflow
Test Steps
- <strong>Create the workflow</strong> - Add all 4 nodes as shown above
- <strong>Activate the workflow</strong> - Toggle it on in settings
- <strong>Send a test message</strong> - Use the test widget or real widget
- Click "Chat with us"<br> - Enter your name and email<br> - Send any message
- <strong>Answer the question</strong> - A question should appear in the widget
- Answer with "2" to test Billing routing<br> - Answer with "1" to test Technical Support routing
- <strong>Check the inbox</strong> - Open the inbox app
- The conversation should appear in the selected inbox
Test Conversation Flow
How It Works (Behind the Scenes)
Customization
Change the Question
In the <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">ask_question</code> node data:
Change the Routing Condition
To route based on different answers:
Add More Than 2 Routes
Use a send_message node to tell customer they'll be routed:
Routing Operators
The condition node supports:
- <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">equals</code> - Exact match
- <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">not_equals</code> - Not exact match
- <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">contains</code> - Substring match (recommended for answers like "2")
- <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">starts_with</code> - Beginning match
Real-World Examples
Example 1: Simple Yes/No Routing
Example 2: Multi-Option Routing
Example 3: Free-Form Routing
Test Results
All routing scenarios tested and passing:
Troubleshooting
Question doesn't appear in widget
<strong>Check:</strong>
- Is the workflow activated? (toggle in settings)
- Is the ask_question node in the correct position in the flow?
- Do the <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">nodeId</code> and <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">nextNodeId</code> values match the flow?
<strong>Test:</strong>
Answer doesn't route correctly
<strong>Check:</strong>
- Is the condition field name correct? (matches variableName in ask_question)
- Is the operator correct? (should be "contains" for "2")
- Are the paths correct? (truePath and falsePath match nodeIds)
<strong>Test:</strong>
Conversation appears in wrong inbox
<strong>Check:</strong>
- Did the condition actually match?
- Is the inboxId in route<em>to</em>inbox node correct?
- Is the inbox ID a real inbox in the workspace?
<strong>Verify:</strong>
Files & Documentation
- Test file: <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">backend/tests/integration/question-answer-routing.test.js</code>
- Routing guide: <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">INBOX<em>ROUTING</em>GUIDE.md</code>
- Test results: <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">WIDGET<em>ROUTING</em>TEST_RESULTS.md</code>
- Implementation: <code style="font-family:ui-monospace,monospace;background:#f1f5f9;color:#dc2626;padding:0.1em 0.35em;border-radius:3px;font-size:0.875em">backend/services/workflowEngine.js</code>
Next Steps
- ✅ Create workflow with ask_question
- ✅ Add condition for routing logic
- ✅ Configure route<em>to</em>inbox nodes
- ✅ Activate workflow
- ✅ Test via widget
- ✅ Monitor routing accuracy
- ⬜ Refine question based on real usage
- ⬜ Add more workflow nodes (send messages, delays, etc.)
Summary
You now have a complete workflow system that:
- Listens for messages
- Asks qualifying questions
- Routes conversations to the right inbox
- All in real-time via Pusher
This is production-ready and tested with 6 passing integration tests.
Did this answer your question?