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

Botpress Deep Dive

Khám phá Botpress - open-source conversational AI platform

🤖 Botpress Deep Dive

Botpress là nền tảng open-source mạnh mẽ cho AI agents.

Giới thiệu Botpress

Tại sao Botpress?

Text
1Ưu điểm:
2✅ Open source (free tier)
3✅ Self-hosting option
4✅ Advanced AI features
5✅ Highly customizable
6✅ Enterprise-ready
7✅ Active development

Botpress vs Voiceflow

Text
1┌─────────────────┬─────────────────┬─────────────────┐
2│ Feature │ Voiceflow │ Botpress │
3├─────────────────┼─────────────────┼─────────────────┤
4│ Ease of use │ ⭐⭐⭐⭐⭐ │ ⭐⭐⭐⭐ │
5│ Customization │ ⭐⭐⭐ │ ⭐⭐⭐⭐⭐ │
6│ Self-hosting │ ❌ │ ✅ │
7│ Open source │ ❌ │ ✅ │
8│ AI features │ ⭐⭐⭐⭐ │ ⭐⭐⭐⭐⭐ │
9│ Community │ ⭐⭐⭐⭐ │ ⭐⭐⭐⭐ │
10└─────────────────┴─────────────────┴─────────────────┘

Getting Started

Create Account

Text
1Steps:
21. Go to botpress.com
32. Sign up for free cloud account
43. Create workspace
54. Create new bot
65. Choose template or blank

Interface Overview

Text
1┌────────────────────────────────────────────────────┐
2│ [Bot Name] [Preview] [Publish] [...]│
3├──────────┬─────────────────────────────────────────┤
4│ Explorer │ │
5│ ──────── │ FLOW EDITOR │
6│ Flows │ │
7│ Tables │ ┌─────┐ ┌─────┐ │
8│ Knowledge│ │Start│────▶│Node │ │
9│ Intents │ └─────┘ └─────┘ │
10│ Entities │ │
11│ ──────── │ │
12│ Settings │ │
13└──────────┴─────────────────────────────────────────┘

Core Concepts

Nodes

Text
1Building blocks:
2- Standard Node: Basic actions
3- AI Task: Generate responses
4- Execute Code: Custom logic
5- Card/Carousel: Rich UI
6- Capture: Collect input

Workflows

Text
1Workflows = Conversations flows
2
3Main workflow: Entry point
4Sub-workflows: Reusable components
5
6Create workflow:
71. Click "+" in Flows
82. Name it
93. Build with nodes
104. Connect with transitions

Variables

Text
1Types:
2- User: Persist across sessions
3- Session: Current session only
4- Workflow: Within workflow
5- Turn: Single turn
6
7Access:
8{{user.name}}
9{{session.orderNumber}}
10{{workflow.step}}

Building with AI

AI Task Node

Text
1The power of Botpress:
21. Add "AI Task" node
32. Define task in natural language:
4 "Analyze the user's message and:
5 - Determine their intent
6 - Extract product name if mentioned
7 - Generate helpful response"
83. Map outputs to variables

Personality

Text
1Set bot personality:
21. Go to Settings → Personality
32. Define:
4 "You are a friendly customer support agent.
5 Be concise, helpful, and professional.
6 Use casual but respectful language."
73. Applied to all AI responses

Knowledge Base

Text
1Add knowledge:
21. Go to Knowledge section
32. Add sources:
4 - Upload files
5 - Add URLs
6 - Manual entries
73. Bot searches automatically
84. Generates contextual answers

Building Support Bot

Main Flow

Text
1Workflow: Main
2├── Start
3├── Greeting
4├── Intent Router
5│ ├── Order Tracking → workflow:tracking
6│ ├── FAQ → Knowledge answer
7│ ├── Complaint → workflow:complaint
8│ └── Unknown → Clarification
9└── End

Greeting Node

Text
1Standard Node:
2Message: "Hi! 👋 I'm here to help. You can:
3- Track your order
4- Get answers to questions
5- Report an issue
6
7What would you like to do?"
8
9Buttons:
10- Track Order
11- Ask Question
12- Report Issue

Intent Recognition

Text
1Botpress AI understands intents automatically!
2
3No need to train:
4- AI parses user message
5- Determines intent
6- Routes appropriately
7
8Configure routing:
9If AI determines "track_order" → Go to tracking
10If AI determines "question" → Search knowledge
11If AI determines "complaint" → Go to complaint

Order Tracking Workflow

Capture Order Number

Text
1Capture Node:
2Question: "What's your order number?"
3Variable: workflow.orderNumber
4Validation: Required
5
6Or AI capture:
7"Extract the order number from user's message"
8→ AI handles various formats

API Integration

Text
1Execute Code node:
2
3const response = await axios.get(
4 `https://api.store.com/orders/${workflow.orderNumber}`,
5 { headers: { 'Authorization': 'Bearer ' + env.API_KEY }}
6);
7
8workflow.orderStatus = response.data.status;
9workflow.deliveryDate = response.data.delivery_date;

Response Node

Text
1Standard Node with conditions:
2
3If {{workflow.orderStatus}} == "delivered":
4 "Great news! Your order was delivered on {{workflow.deliveryDate}}"
5
6If {{workflow.orderStatus}} == "shipped":
7 "Your order is on the way! Expected: {{workflow.deliveryDate}}"
8
9Default:
10 "Your order is being prepared. We'll update you soon!"

Advanced Features

Execute Code

Text
1Custom JavaScript:
2
3// Calculate shipping
4const weight = workflow.items.reduce((sum, item) =>
5 sum + item.weight, 0);
6
7if (weight < 1) {
8 workflow.shipping = 5.99;
9} else if (weight < 5) {
10 workflow.shipping = 9.99;
11} else {
12 workflow.shipping = 14.99;
13}

Tables (Database)

Text
1Botpress Tables = Built-in database
2
3Create table: customers
4Columns:
5- email (text)
6- name (text)
7- orders (number)
8- tier (text)
9
10Use in nodes:
11- Query data
12- Update records
13- Create entries

Hooks

Text
1Trigger code at events:
2
3Before Incoming:
4- Modify/filter messages
5- Add context
6
7After Incoming:
8- Log analytics
9- Update user data
10
11Before Outgoing:
12- Modify responses
13- Add tracking

Multi-Language

Setup

Text
11. Enable languages in settings
22. Add translations for messages
33. Detect user language:
4 - Auto-detect
5 - Ask user
6 - Based on location
74. AI responds in detected language

Translate Flows

Text
1For each message:
21. Click translate icon
32. Add translations:
4 - English: "Hello!"
5 - Vietnamese: "Xin chào!"
6 - Spanish: "¡Hola!"
73. Auto-switches based on user

Human Handoff

When to Handoff

Text
1Triggers:
2- User requests human
3- Agent confidence low
4- Negative sentiment
5- Multiple failures
6- Specific topics

Implementation

Text
1Handoff Node:
21. Collect user info
32. Create ticket in CRM
43. Notify support team
54. Message: "Connecting you to a human agent..."
65. Transfer conversation

Integrations

Text
1Connect to:
2- Zendesk
3- Intercom
4- Salesforce
5- Custom systems

Testing & Debugging

Emulator

Text
1Built-in testing:
21. Click "Preview" or press Ctrl+E
32. Chat with your bot
43. See debug info:
5 - Current node
6 - Variables
7 - AI reasoning

Logs

Text
1View logs:
2- Conversation history
3- AI decisions
4- Errors
5- API calls
6- Performance metrics

Common Issues

Debug Tips
Text
1AI not understanding:
2- Check personality settings
3- Add knowledge base context
4- Review AI task prompts
5
6Variables not saving:
7- Check variable scope
8- Verify capture nodes
9- Review workflow connections
10
11API failures:
12- Check credentials
13- Verify URLs
14- Test externally first

Publishing

Channels

Text
1Deploy to:
2- Web chat widget
3- Facebook Messenger
4- WhatsApp
5- Telegram
6- Slack
7- Custom (API)

Web Widget

Text
11. Go to Integrations
22. Enable Web Chat
33. Customize:
4 - Colors
5 - Position
6 - Messages
74. Get embed code
85. Add to website

Bài Tập

Practice

Build Botpress Support Agent:

  1. Create new bot
  2. Set up knowledge base
  3. Build main conversation flow
  4. Create order tracking workflow
  5. Add AI task nodes
  6. Implement human handoff
  7. Test thoroughly
  8. Deploy web widget

Tiếp theo: Bài 5 - Voice AI Basics