Lý thuyết
45 phút
Bài 3/15

Building with Voiceflow

Xây dựng conversation flows phức tạp với Voiceflow

🔨 Building with Voiceflow

Xây dựng AI agent hoàn chỉnh với advanced features.

Project: Support Agent

What We'll Build

Text
1Support Agent capabilities:
2- Answer FAQs
3- Track orders
4- Handle complaints
5- Escalate to human
6- Knowledge base search

Setting Up Knowledge Base

Why Knowledge Base?

Text
1Instead of:
2- Hard-coding every answer
3- Creating endless flows
4
5Use Knowledge Base:
6- Upload documents
7- Agent searches & answers
8- Easy to update
9- Scales better

Adding Knowledge

Text
1Steps:
21. Go to Knowledge Base section
32. Click "Add Data Source"
43. Options:
5 - Upload files (PDF, TXT)
6 - Add URLs
7 - Manual text entry
84. Process documents
95. Agent can now search

Document Types

Text
1Supported:
2- PDF documents
3- Text files
4- Web pages (URLs)
5- CSV/spreadsheets
6- Google Docs (via URL)

Building FAQ Flow

Knowledge Base Block

Text
1Setup:
21. Add "AI Knowledge" block
32. Configure:
4 - Question: {last_utterance}
5 - Search knowledge base
6 - Generate answer
73. Handle no results:
8 - Fallback message
9 - Offer alternatives

Example Flow

Text
1┌─────────┐ ┌───────────┐ ┌──────────┐
2│ User │────▶│ Knowledge │────▶│ Response │
3│ Question│ │ Search │ │ │
4└─────────┘ └───────────┘ └──────────┘
5
6 ▼ (not found)
7 ┌────────────┐
8 │ Fallback: │
9 │ "Let me │
10 │ connect │
11 │ you..." │
12 └────────────┘

Order Tracking Flow

Collecting Order Number

Text
1Flow:
21. "What's your order number?"
32. Listen block (capture entity)
43. Validate format
54. Call API to get status
65. Display result

Entity Extraction

Text
1Listen block config:
2- Custom entity: @order_number
3- Pattern: alphanumeric
4- Store in: {order_number}

API Integration

Text
1Integration block:
21. Add "Integration" block
32. Select "Custom API"
43. Configure:
5 - URL: https://api.store.com/orders/{order_number}
6 - Method: GET
7 - Headers: API key
84. Store response in variable

Display Results

Text
1Parse API response:
21. Set variables from response
3 - {order_status}
4 - {delivery_date}
5 - {tracking_url}
6
72. Talk block:
8 "Your order #{order_number}
9 Status: {order_status}
10 Expected: {delivery_date}
11 Track: {tracking_url}"

Complaint Handling Flow

Sentiment Detection

Text
1Before routing:
21. Analyze message sentiment
32. Route accordingly:
4 - Positive → Normal flow
5 - Negative → Empathy response
6 - Very negative → Human handoff

Empathy Responses

Text
1AI Response block:
2"You are a customer service agent.
3The customer is frustrated about: {last_utterance}
4
5Respond with:
61. Acknowledge their frustration
72. Apologize sincerely
83. Offer specific help
94. Keep it brief (2-3 sentences)"

Escalation Flow

Text
1When to escalate:
2- User requests human
3- Multiple failures
4- High sentiment score
5- Specific keywords
6
7Escalation block:
81. Collect user info
92. Create support ticket
103. Notify team
114. Confirm to user

Using Conditions

If/Else Logic

Text
1Condition block:
2If {order_status} = "delivered"
3 → "Your order was delivered on {date}"
4Else if {order_status} = "shipped"
5 → "Your order is on the way!"
6Else
7 → "We're preparing your order"

Multiple Conditions

Text
1Chain conditions:
21. Check intent
32. Check entity values
43. Check variables
54. Check time/date

Expression Examples

Text
1Comparisons:
2- {value} = "text"
3- {number} > 100
4- {status} != "cancelled"
5
6Logic:
7- {a} AND {b}
8- {a} OR {b}
9- NOT {condition}
10
11Contains:
12- {text} contains "refund"

Set Variables Block

Calculate Values

Text
1Set block uses:
2- Store user input
3- Calculate values
4- Transform data
5- Set flags
6
7Examples:
8- {total} = {price} * {quantity}
9- {is_premium} = true
10- {formatted_date} = format({date})

Arrays/Lists

Text
1Working with lists:
2- {items} = push({items}, "new item")
3- {first} = {items}[0]
4- {count} = length({items})

Go-To Block

Navigate Flows

Text
1Reuse flows:
21. Create sub-flow (e.g., "Collect Email")
32. Use Go-To to jump to flow
43. Return when complete
54. Avoid duplication

Topic Jumping

Text
1Let users switch topics:
2User: "Actually, I want to track an order"
3
4Go-To block:
5- Detect intent change
6- Jump to relevant flow
7- Maintain context if needed

Carousels & Cards

Rich Responses

Text
1Beyond text responses:
2- Image cards
3- Carousels
4- Buttons
5- Quick replies
6- Links

Carousel Setup

Text
1Display products:
21. Add Carousel block
32. Configure cards:
4 - Image
5 - Title
6 - Description
7 - Button
83. Dynamic data from variables/API

Testing Strategies

Conversation Testing

Text
1Test scenarios:
21. Happy path (everything works)
32. Edge cases (unusual inputs)
43. Error handling (API fails)
54. Intent confusion
65. Multi-turn conversations

Test Checklist

Test These
Text
1☐ Welcome flow works
2☐ All intents recognized
3☐ Entities extracted correctly
4☐ API integrations work
5☐ Knowledge base returns results
6☐ Fallbacks trigger properly
7☐ Escalation works
8☐ Variables persist
9☐ Loops don't occur
10☐ End conversations properly

Debugging

Common Issues

Debug Tips
Text
1Flow not progressing:
2- Check connections
3- Verify conditions
4- Test in isolation
5
6Intent mismatch:
7- Add training phrases
8- Check entity conflicts
9- Review NLU settings
10
11API errors:
12- Verify URL
13- Check authentication
14- Test endpoint externally
15
16Variables empty:
17- Confirm capture
18- Check scope
19- Review block order

Debug Mode

Text
1In preview:
21. Enable debug panel
32. See current block
43. View all variables
54. Track flow path
65. Identify issues

Publishing Agent

Channels

Text
1Deploy to:
2- Web widget
3- Slack
4- Discord
5- WhatsApp (via integration)
6- Custom (API)

Web Widget

Text
11. Go to Publish
22. Select Web Widget
33. Customize appearance
44. Copy embed code
55. Add to website

Bài Tập

Practice

Build Support Agent:

  1. Set up knowledge base with FAQs
  2. Create order tracking flow
  3. Add complaint handling
  4. Implement escalation
  5. Test all flows
  6. Publish web widget

Tiếp theo: Bài 4 - Botpress Deep Dive