E-commerce order management workflow

Build an AI customer service workflow that handles orders, returns, and support using Vapi workflows.

Overview

Build an AI-powered e-commerce customer service workflow that handles order inquiries, returns, and customer support using Vapi workflows with tier-based routing and global monitoring for comprehensive automation.

What You’ll Build:

  • Order tracking with real-time status updates
  • Return processing with automated eligibility verification
  • Customer tier routing (VIP, Premium, Standard)
  • Global fraud detection and sentiment monitoring

Prerequisites

  • A Vapi account.
  • E-commerce platform or order management system.
  • Shipping carrier integrations.

Scenario

We will be creating an order management workflow for TechGear Online, an electronics retailer that wants to automate customer service calls and improve order resolution times through sophisticated workflow automation.

Final Workflow

E-commerce support workflow showing customer identification, inquiry routing, order tracking, and return processing flows
Complete e-commerce customer service workflow with order tracking, return processing, and VIP customer routing

1. Create a Knowledge Base

3

Upload the spreadsheets

  • Click Choose file. Upload all four CSV files: customers.csv, orders.csv, products.csv, and returns.csv.
  • Note the file IDs. We’ll need them later to create tools.

2. Create Required Tools

Before building the workflow, create the necessary tools in your dashboard:

2

Create Customer Lookup Tool

Click Create Tool and configure:

  • Tool Name: “Customer Lookup”
  • Tool Type: “Function”
  • Function Name: lookup_customer
  • Description: “Look up customer account and order history”
  • Parameters:
    • customer_id (string): Customer ID to lookup
  • Server URL: https://jsonplaceholder.typicode.com/users

This example uses JSONPlaceholder, a free testing API. In production, replace with your actual e-commerce API endpoint.

3

Create Order Tracking Tool

Create another tool:

  • Tool Name: “Order Tracking”
  • Function Name: track_order
  • Description: “Track order status and shipping information”
  • Parameters:
    • order_id (string): Order ID to track
  • Server URL: https://jsonplaceholder.typicode.com/posts

This example uses JSONPlaceholder for demonstration. Replace with your shipping provider’s API (FedEx, UPS, etc.) in production.

4

Create Return Processing Tool

Create a third tool:

  • Tool Name: “Return Processing”
  • Function Name: process_return
  • Description: “Process return requests and generate return labels”
  • Parameters:
    • order_id (string): Original order ID
    • return_reason (string): Reason for return
  • Server URL: https://jsonplaceholder.typicode.com/posts

This example uses JSONPlaceholder for demonstration. In production, integrate with your returns management system.


3. Create a Workflow

1

Open the Vapi Dashboard

Go to dashboard.vapi.ai and log in to your account.

3

Create a new workflow

  • Click Create Workflow.
  • Enter workflow name: TechGear E-commerce Support Workflow.
  • Select the default template (includes Call Start node).
  • Click “Create Workflow”.

4. Build the Workflow

You’ll start with a default template that includes a “Call Start” node. We’ll modify the existing nodes and add new ones to create our e-commerce customer service workflow.

1

Configure the Initial Conversation Node

The default template includes a conversation node. Click on it and configure:

Node Name: greeting_and_inquiry_type

First Message
Hello! Thank you for calling TechGear Online customer service. This is Emma, your virtual assistant. I can help you track orders, process returns, answer product questions, or resolve any issues. How can I assist you today?
Prompt
You are Emma, the friendly customer service representative for TechGear Online.
Listen to the customer's response and determine their inquiry type:
- "order_tracking" for checking order status or shipping
- "return_exchange" for returns, exchanges, or refunds
- "product_inquiry" for product questions or recommendations
- "billing_payment" for payment or billing issues
- "complaint" for problems or complaints
- "general" for other inquiries
Keep responses friendly and under 35 words. Be helpful and professional.

Extract Variables:

  • Variable: inquiry_type
  • Type: String
  • Description: The customer's inquiry type
  • Enum Values: order_tracking, return_exchange, product_inquiry, billing_payment, complaint, general
2

Add Customer Identification Node

Add a Conversation node:

Condition
Inquiry type identified

Node Name: customer_identification

First Message
I'll be happy to help you with that. To look up your account, can you please provide your phone number or email address associated with your TechGear Online account?
Prompt
You are collecting customer information to look up their account.
If you don't have an account, that's okay - I can still help you with general product questions.
Be patient and helpful. Extract phone number or email clearly.
Keep responses under 25 words.

Variable Extraction:

  • Variable: customer_phone
  • Type: string
  • Description: Customer's phone number
  • Required: false

  • Variable: customer_email
  • Type: string
  • Description: Customer's email address
  • Required: false
3

Add Customer Lookup Tool Node

Add a Tool node:

Condition
Customer information provided

Tool: Select your pre-configured “Customer Lookup” tool from the dropdown. This tool should be created in the Tools section of your dashboard with:

  • Function Name: lookup_customer
  • Description: “Look up customer account and order history”
  • Parameters:
    • customer_id (string): Customer ID to lookup
  • Server URL: https://jsonplaceholder.typicode.com/users
4

Add Inquiry-Based Routing

Create branching paths based on the customer’s inquiry type. Add multiple conversation nodes:

Order Tracking Node:

Condition
Customer verified and inquiry is order tracking

Node Name: order_tracking_flow

First Message
I can help you track your order. Do you have your order number, or would you like me to look up your recent orders?
Prompt
You are helping the customer track their order.
Be proactive in finding their order information.
If they don't have the order number, offer to look up recent orders.
Keep responses under 30 words.

Return/Exchange Node:

Condition
Customer verified and inquiry is return or exchange

Node Name: return_exchange_flow

First Message
I can help you with returns and exchanges. Can you tell me which item you'd like to return and the reason for the return?
Prompt
You are helping the customer with a return or exchange.
Get the specific item and reason for return clearly.
Be understanding and helpful about their concerns.
Keep responses under 30 words.

Product Inquiry Node:

Condition
Customer verified and inquiry is product related

Node Name: product_inquiry_flow

First Message
I'd be happy to help with product information. What specific product are you interested in, or what type of device are you looking for?
Prompt
You are helping the customer with product information and recommendations.
Be knowledgeable about TechGear products and helpful in making recommendations.
Ask clarifying questions to better assist them.
Keep responses under 35 words.

Billing/Payment Node:

Condition
Customer verified and inquiry is billing or payment

Node Name: billing_payment_flow

First Message
I can help with billing and payment questions. Are you looking to update payment information, dispute a charge, or have questions about a specific order?
Prompt
You are helping the customer with billing and payment issues.
Be careful with sensitive financial information.
Determine the specific billing concern clearly.
Keep responses under 30 words.

Complaint Resolution Node:

Condition
Customer verified and inquiry is a complaint

Node Name: complaint_resolution_flow

First Message
I'm sorry to hear you're having an issue. I want to make this right for you. Can you tell me what happened so I can help resolve this?
Prompt
You are handling a customer complaint and working toward resolution.
Be empathetic and solution-focused. Listen carefully to their concern.
Show that you care about resolving their issue.
Keep responses under 35 words.
5

Configure Flow Conditions

Connect the nodes with conditions for the LLM to interpret:

To Order Tracking Node:

  • Condition: Customer verified and inquiry is order tracking

To Return/Exchange Node:

  • Condition: Customer verified and inquiry is return or exchange

To Product Inquiry Node:

  • Condition: Customer verified and inquiry is product related

To Billing/Payment Node:

  • Condition: Customer verified and inquiry is billing or payment

To Complaint Resolution Node:

  • Condition: Customer verified and inquiry is a complaint
6

Add Global VIP Customer Handler

Create a global node that provides special handling for VIP customers:

Condition
VIP customer detected

Node Name: vip_customer_handler Global Node: enabled = true Enter Condition: {{ customer_tier == "VIP" or total_orders > 50 or lifetime_value > 5000 }}

First Message
I see you're one of our valued VIP customers. I want to make sure you receive our highest level of service today. Let me prioritize your request and see what I can do to exceed your expectations.
Prompt
You are providing VIP-level customer service to a high-value customer.
Be extra attentive and go above and beyond normal service.
Offer premium solutions and expedited handling.
Keep responses under 35 words but show special attention.

This global node will activate for high-value customers, regardless of their inquiry type.

7

Add VIP Customer Priority Node

Node Name: vip_customer_priority

First Message
Thank you for being a valued VIP customer! I'm prioritizing your call and will personally ensure your issue is resolved quickly. How can I assist you today?
Prompt
You are providing VIP-level customer service.
Give this customer premium attention and faster resolution.
Be extra helpful and offer additional assistance.
Keep responses under 30 words.
8

Add Order Status and Tracking Flows

Order Number Collection Node:

Condition
Order tracking flow initiated

Node Name: collect_order_number

First Message
Please provide your order number, and I'll get the latest status for you right away.
Prompt
You are collecting the order number for tracking.
Be patient if they need time to find it.
Offer alternative methods if they can't locate the order number.
Keep responses under 25 words.

Extract Variables:

  • Variable: order_number
  • Type: string
  • Description: Customer's order number

Order Tracking Tool Node:

Condition
Order number provided
  • Add a Tool node that calls your order tracking API with order information

Shipping Information Node:

Condition
Order status retrieved

Node Name: provide_shipping_info

First Message
Great news! Your order is [status] and should arrive [delivery date]. Here's your tracking number: [tracking]. Is there anything else about this order?
Prompt
You are providing order status and shipping information to the customer.
Give clear updates on order status, tracking, and delivery estimates.
Be positive and informative. Keep responses under 35 words.
  • Present tracking details, delivery estimates, and shipping updates
9

Add Return Processing Flow

Return Eligibility Check Node:

Condition
Return request initiated

Node Name: check_return_eligibility

First Message
Let me check if this item is eligible for return. What's the reason for the return - defective, wrong item, or just not what you expected?
Prompt
You are checking return eligibility and gathering return details.
Verify return policy compliance and item condition.
Be understanding about their return reason.
Keep responses under 30 words.

Extract Variables:

  • Variable: return_reason
  • Type: String
  • Description: Reason for return

Return Authorization Tool Node:

Condition
Return eligibility confirmed
  • Add a Tool node that creates return label and authorization number

Refund Processing Node:

Condition
Return authorized

Node Name: process_refund

First Message
Perfect! I've processed your return authorization. You'll receive a return label via email, and your refund will be processed within 3-5 business days once we receive the item.
Prompt
You are confirming the return process and refund timeline.
Provide clear instructions for returning the item.
Set proper expectations for refund timing.
Keep responses under 35 words.
  • Handle refund calculations and payment processing
10

Add Escalation and Resolution Options

Human Agent Transfer Node:

Condition
Customer requests human agent or complex issue

Node Type: Transfer Destination: +1-555-SUPPORT (customer service team)

Issue Resolution Node:

Condition
Resolution offered or compensation provided

Node Name: resolve_issue

First Message
I want to make this right for you. Let me offer you [solution/compensation] for the trouble you've experienced.
Prompt
You are providing a resolution or compensation for the customer's issue.
Be generous and solution-focused. Make the customer feel valued.
Offer specific solutions or compensation when appropriate.
Keep responses under 30 words.
  • Provide solutions, credits, or compensations

End Call Node:

Condition
Customer issue resolved and satisfied

Node Type: Hangup

  • Use when customer issue is resolved

5. Configure Phone Number

2

Create or Import Phone Number

  • Click Create Phone Number for a new Vapi number, or
  • Click Import Phone Number to use your existing customer service number
3

Configure Inbound Settings

Workflow: Select your TechGear Customer Service Workflow

Customer Service Configuration:

  • Enable call recording for quality assurance
  • Set maximum call duration (e.g., 30 minutes for complex issues)
  • Configure voicemail for after-hours support
  • Enable priority routing for VIP customers
4

Test Customer Service Scenarios

Test the workflow with various customer scenarios:

  • Order tracking requests
  • Return and exchange processing
  • Product inquiries and recommendations
  • Billing and payment issues
  • Complaint resolution

Optional: Web SDK Integration

For e-commerce websites that want to integrate voice support directly into their shopping experience:

1import Vapi from '@vapi-ai/web';
2
3interface EcommerceOrderConfig {
4 publicApiKey: string;
5 workflowId: string;
6}
7
8function createEcommerceOrderWorkflow(config: EcommerceOrderConfig) {
9 const vapi = new Vapi(config.publicApiKey);
10 let isConnected = false;
11 let currentCustomer: any = null;
12
13 // Setup event listeners for customer service calls
14 vapi.on('call-start', () => {
15 isConnected = true;
16 console.log('E-commerce customer service call started');
17 });
18
19 vapi.on('call-end', () => {
20 isConnected = false;
21 console.log('Customer service call ended');
22 processCustomerServiceOutcome();
23 });
24
25 vapi.on('message', (message) => {
26 if (message.type === 'transcript') {
27 console.log(`${message.role}: ${message.transcript}`);
28 } else if (message.type === 'function-call') {
29 handleCustomerServiceFunction(message.functionCall);
30 } else if (message.type === 'workflow-step') {
31 console.log('Customer service workflow step:', message.step);
32 }
33 });
34
35 vapi.on('error', (error) => {
36 console.error('Customer service workflow error:', error);
37 });
38
39 function handleCustomerServiceFunction(functionCall: { name: string; parameters: Record<string, unknown> }) {
40 switch (functionCall.name) {
41 case 'lookup_customer':
42 console.log('Looking up customer:', functionCall.parameters);
43 break;
44 case 'track_order':
45 console.log('Tracking order:', functionCall.parameters);
46 break;
47 case 'process_return':
48 console.log('Processing return:', functionCall.parameters);
49 break;
50 default:
51 console.log('Customer service function called:', functionCall.name, functionCall.parameters);
52 }
53 }
54
55 function processCustomerServiceOutcome() {
56 console.log('Processing customer service outcome for:', currentCustomer);
57 }
58
59 return {
60 startCustomerServiceCall: (customerData?: any) => {
61 if (!isConnected) {
62 currentCustomer = customerData;
63 vapi.start(config.workflowId);
64 }
65 },
66 endCall: () => {
67 if (isConnected) {
68 vapi.stop();
69 }
70 },
71 isConnected: () => isConnected
72 };
73}
74
75// Usage for e-commerce customer service integration
76const customerServiceWorkflow = createEcommerceOrderWorkflow({
77 publicApiKey: 'YOUR_PUBLIC_API_KEY',
78 workflowId: 'YOUR_WORKFLOW_ID'
79});
80
81// Add to your e-commerce site's customer service button
82document.getElementById('customer-service-button')?.addEventListener('click', () => {
83 customerServiceWorkflow.startCustomerServiceCall({
84 customerId: 'current_customer_id',
85 currentPage: 'order_tracking',
86 context: 'website_support'
87 });
88});

Web SDK is for client-side customer service integration. File uploads and workflow creation must use the Server SDK or Dashboard.


Integrating with Real Systems

This example uses JSONPlaceholder for demonstration purposes. To integrate with your actual e-commerce systems:

E-commerce Platform Integration

Shipping Provider APIs

Payment Processing

Next Steps

Just like that, you’ve built an e-commerce customer service workflow that can handle order inquiries, returns, and support requests with 24/7 availability for your online store.

Consider reading the following guides to further enhance your workflow:

  • Custom Tools - Create custom tools for e-commerce platform integration and order management.
  • Custom Voices - Customize your assistant’s voice for customer service excellence.
  • Call Recording - Record calls for quality assurance and training purposes.