Overview
This guide shows you how to build a call flow that uses a Database Query node to look up caller information and route calls based on the result. This pattern is useful for identifying callers by their phone number and providing personalized routing — for example, greeting VIP customers by name or routing them to a dedicated agent.
Requirement: The Call Flow Designer requires the Ultimate Plan.
Scenario
A company maintains a customer database and wants the following behavior when a call comes in:
- The system looks up the caller's phone number in the database.
- If the caller is found and marked as a VIP, play a personalized greeting and transfer to a priority queue.
- If the caller is found but not a VIP, transfer to the standard queue.
- If the caller is not found, play a general greeting and present an IVR menu.
Prerequisites
- A database configured under Call Flow Designer > Database with at least the following columns:
- Phone number (the lookup key)
- Customer name
- Customer type (e.g., "VIP" or "Standard")
- A priority queue or ring group for VIP customers.
- A standard queue for regular callers.
- Voice prompts for greetings (optional — can use TTS if configured).
Step 1. Set up the database
Before building the call flow, you need a database with customer data:
- Go to Call Flow Designer > Database.
- Click Add to create a new database.
- Enter a name (e.g., "Customer Directory").
- Define the columns: phone_number, customer_name, customer_type.
- Add your customer records manually or import them from a CSV file.
Tip: Store phone numbers in E.164 format (e.g., +491701234567) to ensure reliable matching with incoming caller IDs.
Step 2. Create the call flow
- Go to Call Flow Designer and click Add.
- Enter a name (e.g., "Customer Lookup — VIP Routing").
- Select Start from Scratch as the creation method.
- Click Save, then click the edit icon to open the visual flow editor.
Step 3. Configure the Initial Action
- Click the Initial Action node on the canvas.
- Under Incoming Call from, select the DID number(s) that should trigger this call flow.
Step 4. Add the Database Query node
- Drag a Database Query node onto the canvas and connect it to the Initial Action.
- Select your database (e.g., "Customer Directory").
- Set the Query Key to the caller's phone number (use the system variable for the caller ID).
- Set the Lookup Column to phone_number.
The Database Query node produces two outputs:
- Match Found — the caller's number exists in the database.
- No Match — the caller's number was not found.
Step 5. Build the "Match Found" branch
When a match is found, you can access the database values (customer name, customer type) in subsequent nodes.
- Drag a Condition node onto the canvas and connect it to the Match Found output.
- Configure the condition to check the customer_type field:
- If customer_type = VIP → route to the VIP branch.
- Otherwise → route to the standard branch.
VIP branch
- Add a Prompt node with a personalized greeting. You can use TTS with the customer name variable (e.g., "Welcome back, {customer_name}. We are connecting you to your dedicated team.").
- Add a Transfer node pointing to the VIP priority queue.
Standard branch
- Optionally add a Prompt node with a greeting.
- Add a Transfer node pointing to the standard queue.
Step 6. Build the "No Match" branch
- Drag a Menu node onto the canvas and connect it to the No Match output.
- Configure a standard IVR menu (e.g., "Press 1 for Sales, press 2 for Support").
- Add Transfer nodes for each menu option.
Step 7. Save and activate
- Click Save.
- Return to the call flow list and enable the call flow using the Status toggle.
- Test by calling from a number that is in the database and from one that is not.
Flow structure
Initial Action (main number)
└── Database Query (Customer Directory, lookup by caller ID)
├── Match Found
│ └── Condition (customer_type)
│ ├── VIP
│ │ └── Prompt (personalized greeting) → Transfer (VIP Queue)
│ └── Standard
│ └── Transfer (Standard Queue)
└── No Match
└── Menu (IVR)
├── Key 1 → Transfer (Sales)
├── Key 2 → Transfer (Support)
└── No match → Prompt (error) → Menu (repeat)Variations
Language-based routing
Add a language column to your database. When a match is found, use a Condition node to check the customer's preferred language and route to a language-specific queue or play prompts in the correct language.
Account number input
Instead of looking up by caller ID, add a Gather node before the Database Query to ask the caller to enter their account number. Use the entered digits as the query key to look up the customer record.
Combine with business hours
Add an Office Hours node before the Database Query. During business hours, perform the lookup and route accordingly. After hours, skip the lookup and play an after-hours message with voicemail.
Tips
- Keep the database updated: Outdated records lead to misrouted calls. Establish a process to regularly update the customer database, either manually or via CSV import.
- Phone number format: Ensure all phone numbers in the database use the same format as the incoming caller ID. Mismatched formats (e.g., with vs. without country code) will cause lookup failures.
- Fallback routing: Always provide a meaningful path for callers not found in the database. Never leave the "No Match" branch empty.
- Test with real numbers: Before activating, test the flow by adding your own phone number to the database and calling in.
Comments
0 comments
Article is closed for comments.