Building a Smart E-Commerce Chatbot with Dialogflow CX and Google Cloud.

Discover how to build a powerful e-commerce chatbot named Shia using Dialogflow CX and Google Cloud services. Learn how it handles customer queries, order tracking, and personalized offers — all while being scalable and cost-effective.
@shadcn

Hitesh Chatree

a month ago

building-a-smart-e-commerce-chatbot-with-dialogflow-cx-and-google-cloud

In today’s digital marketplace, e-commerce brands strive to enhance customer service while managing operational efficiency. In this guide, we introduce Shia — an intelligent chatbot built using Dialogflow CX and Google Cloud, enabling customers to shop, track orders, and get support through natural conversations.

Challenges Faced by E-Commerce Platforms

Online retailers often encounter the following issues when trying to scale:

  • Addressing repetitive customer queries (e.g., order updates, product availability)

  • Providing round-the-clock support without extensive hiring

  • Offering tailored shopping experiences to each customer

  • Maintaining a consistent tone and service across multiple platforms

Introducing Shia – The AI Assistant for Online Shopping

Shia is a cutting-edge chatbot that creates an interactive, human-like shopping journey. Built on Google Cloud’s flexible and powerful tools, it can manage everything from browsing products to resolving issues seamlessly.

Key Features

  • Smart Search – Filter products and get personalized suggestions

  • Order Updates – Track your purchases in real-time

  • Account Services – Manage user information and preferences

  • Issue Handling – Report complaints and escalate problems

  • Custom Deals – Receive offers and discounts based on behavior

How It’s Built: Tech Stack Overview

Shia operates on a hub-and-spoke model consisting of:

  1. Dialogflow CX – Core engine for managing dialogues

  2. Cloud Functions / Cloud Run – Backend execution layer

  3. BigQuery – High-performance data storage and analytics

In-Depth Component Breakdown

1. Dialogflow CX – The Conversation Designer

Shia’s chatbot logic is organized into state-based flows such as:

  • Start Page – Initial greeting and routing

  • MAIN_MENU – Central control for options

  • ORDER_STATUS – Retrieves order tracking info

  • BROWSE_PRODUCTS – Product catalog and filters

  • COMPLAINT – Logs and escalates user issues

  • MY_ACCOUNT – Manages user settings

  • OFFER – Delivers special offers

2. Cloud Functions – Backend Processing

These serverless functions handle:

  • Querying BigQuery for relevant information

  • Connecting to external inventory/order systems

  • Returning dynamic replies to users

Example: Order Lookup Webhook

python

CopyEdit

def get_order_details(request_json): order_id = request_json["sessionInfo"]["parameters"]["order_id"] # BigQuery logic and response formatting here

3. BigQuery – Data Infrastructure

Stores essential datasets like:

  • Product details

  • Customer orders

  • User accounts

  • Chat logs

  • Performance metrics

Key Functional Highlights

1. Dynamic Discount Generator

Users receive unique offers by picking a number:

python

CopyEdit

def generate_offer(request_json): offers = { 1: "10% OFF with code TRR10", 2: "Free shipping on $50+ with code FREESHIP50", # more options... } return offers[user_number]

2. Performance Monitoring Metrics

Shia tracks and improves based on:

  • Goal completion rate: >85%

  • Intent accuracy: >90%

  • Fallback response rate: <15%

  • Avg. interaction length: <8 turns

  • User satisfaction: >4.2/5

  1. Sample SQL Query for Fallback Rate

sql

CopyEdit

SELECT DATE(timestamp) AS date, COUNT(CASE WHEN intent = 'Default Fallback Intent' THEN 1 END) / COUNT(*) * 100 AS fallback_rate FROM ecommerce_data.conversations GROUP BY date ORDER BY date DESC LIMIT 14;

Steps to Build Your Own Chatbot

  1. Start Your GCP Project

bash

CopyEdit

gcloud projects create your-project-id gcloud services enable dialogflow.googleapis.com cloudfunctions.googleapis.com bigquery.googleapis.com

  1. Create BigQuery tables for your catalog, orders, users, and interactions

  2. Deploy webhook code with Cloud Functions:

bash

CopyEdit

gcloud functions deploy orderStatus --runtime python39 --trigger-http

  1. Set up Dialogflow CX

    • Define conversation flows

    • Configure intents and entities

    • Integrate webhooks

    • Connect to frontend interfaces (website/app/chat)

What’s Next? Future Upgrades

This modular system supports easy upgrades, such as:

Support for multiple languages
Voice assistant capabilities
Smarter product recommendations
Built-in payment functionality
Real-time sentiment detection

Final Thoughts

Creating an AI-powered e-commerce chatbot like Shia using Dialogflow CX and Google Cloud helps retailers deliver a seamless, efficient, and engaging customer experience. With minimal infrastructure management and high scalability, it’s an ideal solution for both growing startups and large enterprises.

As conversational AI continues to evolve, smart assistants like Shia will become a key driver of online retail success.