🤖 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 option4✅ Advanced AI features5✅ Highly customizable6✅ Enterprise-ready7✅ Active developmentBotpress 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.com32. Sign up for free cloud account43. Create workspace54. Create new bot65. Choose template or blankInterface 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 actions3- AI Task: Generate responses4- Execute Code: Custom logic5- Card/Carousel: Rich UI6- Capture: Collect inputWorkflows
Text
1Workflows = Conversations flows2 3Main workflow: Entry point4Sub-workflows: Reusable components5 6Create workflow:71. Click "+" in Flows82. Name it93. Build with nodes104. Connect with transitionsVariables
Text
1Types:2- User: Persist across sessions3- Session: Current session only4- Workflow: Within workflow5- Turn: Single turn6 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" node32. Define task in natural language:4 "Analyze the user's message and:5 - Determine their intent6 - Extract product name if mentioned7 - Generate helpful response"83. Map outputs to variablesPersonality
Text
1Set bot personality:21. Go to Settings → Personality32. 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 responsesKnowledge Base
Text
1Add knowledge:21. Go to Knowledge section32. Add sources:4 - Upload files5 - Add URLs6 - Manual entries73. Bot searches automatically84. Generates contextual answersBuilding Support Bot
Main Flow
Text
1Workflow: Main2├── Start3├── Greeting4├── Intent Router5│ ├── Order Tracking → workflow:tracking6│ ├── FAQ → Knowledge answer7│ ├── Complaint → workflow:complaint8│ └── Unknown → Clarification9└── EndGreeting Node
Text
1Standard Node:2Message: "Hi! 👋 I'm here to help. You can:3- Track your order4- Get answers to questions5- Report an issue6 7What would you like to do?"8 9Buttons:10- Track Order11- Ask Question 12- Report IssueIntent Recognition
Text
1Botpress AI understands intents automatically!2 3No need to train:4- AI parses user message5- Determines intent6- Routes appropriately7 8Configure routing:9If AI determines "track_order" → Go to tracking10If AI determines "question" → Search knowledge11If AI determines "complaint" → Go to complaintOrder Tracking Workflow
Capture Order Number
Text
1Capture Node:2Question: "What's your order number?"3Variable: workflow.orderNumber4Validation: Required5 6Or AI capture:7"Extract the order number from user's message"8→ AI handles various formatsAPI 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 shipping4const 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 database2 3Create table: customers4Columns:5- email (text)6- name (text)7- orders (number)8- tier (text)9 10Use in nodes:11- Query data12- Update records13- Create entriesHooks
Text
1Trigger code at events:2 3Before Incoming:4- Modify/filter messages5- Add context6 7After Incoming:8- Log analytics9- Update user data10 11Before Outgoing:12- Modify responses13- Add trackingMulti-Language
Setup
Text
11. Enable languages in settings22. Add translations for messages33. Detect user language:4 - Auto-detect5 - Ask user6 - Based on location74. AI responds in detected languageTranslate Flows
Text
1For each message:21. Click translate icon32. Add translations:4 - English: "Hello!"5 - Vietnamese: "Xin chào!"6 - Spanish: "¡Hola!"73. Auto-switches based on userHuman Handoff
When to Handoff
Text
1Triggers:2- User requests human3- Agent confidence low4- Negative sentiment5- Multiple failures6- Specific topicsImplementation
Text
1Handoff Node:21. Collect user info32. Create ticket in CRM43. Notify support team54. Message: "Connecting you to a human agent..."65. Transfer conversationIntegrations
Text
1Connect to:2- Zendesk3- Intercom4- Salesforce5- Custom systemsTesting & Debugging
Emulator
Text
1Built-in testing:21. Click "Preview" or press Ctrl+E32. Chat with your bot43. See debug info:5 - Current node6 - Variables7 - AI reasoningLogs
Text
1View logs:2- Conversation history3- AI decisions4- Errors5- API calls6- Performance metricsCommon Issues
Debug Tips
Text
1AI not understanding:2- Check personality settings3- Add knowledge base context4- Review AI task prompts5 6Variables not saving:7- Check variable scope8- Verify capture nodes9- Review workflow connections10 11API failures:12- Check credentials13- Verify URLs14- Test externally firstPublishing
Channels
Text
1Deploy to:2- Web chat widget3- Facebook Messenger4- WhatsApp5- Telegram6- Slack7- Custom (API)Web Widget
Text
11. Go to Integrations22. Enable Web Chat33. Customize:4 - Colors5 - Position6 - Messages74. Get embed code85. Add to websiteBài Tập
Practice
Build Botpress Support Agent:
- Create new bot
- Set up knowledge base
- Build main conversation flow
- Create order tracking workflow
- Add AI task nodes
- Implement human handoff
- Test thoroughly
- Deploy web widget
Tiếp theo: Bài 5 - Voice AI Basics
