Skip to content

Creating a Virtual Assistant with Voiceflow

Build conversational AI assistants using Voiceflow’s visual interface, integrate with OpenAI, and deploy across messaging platforms.

What you’ll build: A customer service virtual assistant with natural language understanding, context management, and multi-channel deployment.

Use cases: Customer support, appointment booking, FAQ automation, lead qualification.

Time: 40 minutes

  • Voiceflow account (free tier available at voiceflow.com)
  • OpenAI API key
  • Deployment channel (WhatsApp Business API, Telegram, or web)
  1. Log into Voiceflow
  2. Click “New Project”
  3. Choose “Chat Assistant”
  4. Select template or start blank

Blocks:

  • Start: Entry point
  • Text: Display messages
  • Capture: Get user input
  • Condition: Branch logic
  • API: External calls
  • Code: Custom logic

Goal: Answer common questions

Flow Design:

Start
Welcome Message
Capture User Question
OpenAI API Call
Display Answer
Ask if helpful?
Yes: Thank you → End
No: Connect to human → End

Implementation:

1. Welcome Block

Type: Text
Message: "Hi! I'm your virtual assistant. How can I help you today?"

2. Capture Input

Type: Capture
Variable: {user_question}
Message: "Please type your question..."

3. OpenAI Integration

Type: API
Method: POST
URL: https://api.openai.com/v1/chat/completions
Headers:
Authorization: Bearer {your_api_key}
Content-Type: application/json
Body:
{
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "You are a helpful customer service assistant. Answer questions concisely and professionally."
},
{
"role": "user",
"content": "{user_question}"
}
]
}
Response Mapping:
answer = response.choices[0].message.content

4. Display Answer

Type: Text
Message: "{answer}"

5. Satisfaction Check

Type: Choice
Message: "Was this helpful?"
Choices:
- Yes → Thank you message → End
- No → "Let me connect you with a human agent" → Handoff

Use Variables to track conversation state:

Variables:
- user_name: String
- user_email: String
- conversation_topic: String
- satisfied: Boolean
- retry_count: Number

Example Flow with Context:

Capture name → Store in {user_name}
All future messages: "Hi {user_name}, ..."
Track topic in {conversation_topic}
If {retry_count} > 3 → Escalate to human

Use Conditions for intent routing:

Condition Block:
IF {user_question} contains ["price", "cost", "pricing"]
→ Go to Pricing Flow
ELSE IF {user_question} contains ["demo", "trial", "test"]
→ Go to Demo Booking Flow
ELSE IF {user_question} contains ["bug", "error", "broken"]
→ Go to Support Flow
ELSE
→ Go to General FAQ Flow

Example: Appointment Booking

Start → Collect Service Type
Collect Preferred Date
Collect Preferred Time
Collect Contact Info
Confirm Details
API Call to Calendar System
Send Confirmation

Implementation:

// Step 1: Collect Service
Text: "What service do you need?"
Choice:
- Consultation
- Support
- Demo
// Step 2: Date Collection
Capture: {preferred_date}
Validation: Must be future date
// Step 3: Time Selection
Choice: Pick from available slots
Buttons:
- 9:00 AM
- 11:00 AM
- 2:00 PM
- 4:00 PM
// Step 4: Contact Info
Capture: {email}
Validation: Must be valid email
// Step 5: Confirmation
Text: "Booking {service} on {date} at {time}. Confirm?"
Choice: Yes/No
// Step 6: API Call (if Yes)
API: POST /api/bookings
Body: {
service: {service},
date: {date},
time: {time},
email: {email}
}
// Step 7: Success Message
Text: "Confirmed! Check {email} for details."
  1. Get WhatsApp Business API access
  2. In Voiceflow: Integrations → WhatsApp
  3. Connect your WhatsApp Business account
  4. Configure webhook URL
  5. Test with your number
  1. Create bot with @BotFather
  2. Get bot token
  3. In Voiceflow: Integrations → Telegram
  4. Paste token
  5. Deploy
<!-- Add to your website -->
<script type="text/javascript">
(function(d, t) {
var v = d.createElement(t), s = d.getElementsByTagName(t)[0];
v.onload = function() {
window.voiceflow.chat.load({
verify: { projectID: 'YOUR_PROJECT_ID' },
url: 'https://general-runtime.voiceflow.com',
versionID: 'production'
});
}
v.src = "https://cdn.voiceflow.com/widget/bundle.mjs";
v.type = "text/javascript"; s.parentNode.insertBefore(v, s);
})(document, 'script');
</script>

Do:

  • Use clear, concise language
  • Provide examples in prompts
  • Offer quick reply buttons
  • Set user expectations early

Don’t:

  • Make conversations too long
  • Use complex jargon
  • Ask for info you already have
  • Leave users in dead ends

Always include:

Try-Catch blocks for API calls
Fallback responses for unknowns
Escalation path to humans
Retry limits for failed inputs

Example:

API Call
Success? → Continue
No → Try again (max 2 times)
Still failing? → "I'm having technical difficulties. Let me connect you to a person."

Improve understanding:

  • Use OpenAI for complex queries
  • Add synonyms to intent matching
  • Implement spell-check
  • Handle common typos

Example NLU Setup:

// Code block in Voiceflow
const userInput = {user_question}.toLowerCase();
// Handle variations
if (userInput.includes('hi') ||
userInput.includes('hello') ||
userInput.includes('hey')) {
setVariable('intent', 'greeting');
}

Track:

  • User drop-off points
  • Common unhandled queries
  • Average conversation length
  • Satisfaction scores

In Voiceflow:

  • Use Analytics dashboard
  • Review conversation logs
  • A/B test different flows
  • Iterate based on data
  1. Happy Path: User gets answer easily
  2. Confused User: Unclear questions
  3. Edge Cases: Unusual inputs
  4. Error Scenarios: API failures
  5. Multi-Intent: Multiple questions at once
□ All intents recognized correctly
□ Variables storing data properly
□ API calls returning expected data
□ Error messages displaying
□ Fallbacks working
□ Handoff to human functional
□ All platforms (WhatsApp, Web, etc.) working
  • Cache frequent responses
  • Use API rate limiting
  • Optimize image/media sizes
  • Set timeouts appropriately
- Validate all user inputs
- Sanitize before API calls
- Don't store sensitive data in variables
- Use HTTPS for all integrations
- Implement rate limiting

Handle high volume:

  • Use queuing for handoffs
  • Load balance API calls
  • Monitor response times
  • Set up alerts for failures

Regular tasks:

  • Review conversation logs weekly
  • Update knowledge base
  • Retrain intents
  • Test new scenarios
  • Update API integrations
Flow:
User Question → Classify Issue Type → Route to:
- Knowledge Base (self-service)
- Ticket Creation (async)
- Live Agent (urgent)
Flow:
Greeting → Collect:
- Company Size
- Industry
- Budget Range
- Timeline
→ Score Lead → Route to Sales
Flow:
Capture Order Number → API Lookup → Display:
- Order Status
- Expected Delivery
- Tracking Link
→ Offer to help with issues

Issue: Bot not responding

  • Check deployment status
  • Verify webhook configuration
  • Test with built-in chat first

Issue: API calls failing

  • Verify API key
  • Check request format
  • Review error logs
  • Test endpoint directly

Issue: Wrong intent detected

  • Add more training phrases
  • Improve intent descriptions
  • Use OpenAI for complex NLU

Enhance your assistant:

  • Add multilingual support
  • Implement sentiment analysis
  • Create specialized flows
  • Integrate with CRM
  • Add voice capabilities

Related guides:


Found an issue? Open an issue!