0% found this document useful (0 votes)
6 views64 pages

Intern Report (Corrected)

This dissertation presents the development of AI-powered solutions aimed at enhancing business efficiency through various applications, including a QR code inspection management system, e-commerce chatbots, and an SQL-querying assistant. The proposed systems address existing inefficiencies in manual processes, improve customer engagement, and facilitate data access for informed decision-making. Technologies utilized include HTML, CSS, JavaScript, Node.js, and MongoDB, with a focus on automating tasks and streamlining operations across different business functions.

Uploaded by

Naveena S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views64 pages

Intern Report (Corrected)

This dissertation presents the development of AI-powered solutions aimed at enhancing business efficiency through various applications, including a QR code inspection management system, e-commerce chatbots, and an SQL-querying assistant. The proposed systems address existing inefficiencies in manual processes, improve customer engagement, and facilitate data access for informed decision-making. Technologies utilized include HTML, CSS, JavaScript, Node.js, and MongoDB, with a focus on automating tasks and streamlining operations across different business functions.

Uploaded by

Naveena S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

AI-POWERED ASSISTANTS FOR BUSINESS EFFICIENCY

NAVEENA S
Register No: 71762134032

DISSERTATION SUBMITTED IN PARTIAL FULFILMENT OF THE


REQUIREMENTS FOR THE DEGREE OF
M.SC. (ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING)
OF ANNA UNIVERSITY, CHENNAI

November 2024

DEPARTMENT OF COMPUTING
(ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING)
COIMBATORE INSTITUTE OF TECHNOLOGY
(Autonomous Institution affiliated to Anna University, Chennai)
COIMBATORE – 641014
COIMBATORE INSTITUTE OF TECHNOLOGY
(Autonomous Institution affiliated to Anna University)
COIMBATORE 641014

Project Work
Seventh Semester

AI-POWERED ASSISTANTS FOR BUSINESS EFFICIENCY

Bonafide record of work done by


NAVEENA S
(Register No: 71762134032)

Submitted in partial fulfillment of the requirements for the degree of


M.Sc.(Artificial Intelligence and Machine Learning) of Anna University,
Chennai

November 2024

___________ __________________
Faculty Guide Head of the Department

Submitted for the viva voce held on_______________

_______________ ______________
Internal Examiner External Examiner
TABLE OF CONTENTS
CHAPTER PAGE-NO
ACKNOWLEDGEMENT i
SYNOPSIS ii
I INTRODUCTION
1.1 ORGANIZATION PROFILE 1
1.2 PROBLEM ANALYSIS 2
II SYSTEM ANALYSIS
2.1 System Environments

2.1.1 Software Requirements 5


2.1.2 Hardware Requirements 5

III METHODOLOGY

3.1 Task 1 – QR-Based Inspection Management System (POC) 12

3.1.1 Problem Statement 6


3.1.2 Software Requirements 6
3.1.3 Use Case Diagram 8
3.1.4 Architecture 9
3.1.5 Module Description 10
3.1.6 System Workflow 12
3.1.7 Application UI Design 12
3.2 Task 2- E-commerce Recommendation System 16

3.2.1 Objective 16
3.2.2 Functional Requirements 16
3.2.3 Use case Diagram 18
3.2.4 Data Preparation 19
3.2.5 Module Description 21
3.2.6 Activity Diagram 23
3.2.7 Ui Design 23

3.3 Task 3-SQL Query Assistant 24

3.3.1 Objective 24
3.3.2 Functional Requirements 24
3.3.3 Use Case Diagram 26
3.3.4 Dataset Design 26
3.3.5 Module Description 26
3.3.6 Activity Diagram 28
3.3.7 Chatbot Design 29

3.4 Task 4-Sales Assistant Chatbot 31

3.4.1 Objective 31
3.4.2 Functional Requirements 31
3.4.3 Use case Diagram 33
3.4.4 Module Description 34
3.4.5 Activity Diagram 36
3.4.6 UI design 37

IV IMPLEMENTATION
4.1 Pseudocode 39

V TESTING
5.1 Test Cases and Reports 48
5.2 Test Screenshots 51
VI CONCLUSION 56
BIBLIOGRAPHY 57
ACKNOWLEDGEMENT

I express my sincere gratitude to all those who have supported and guided me throughout
the development of this project. Their assistance and encouragement have been invaluable to
my work and growth.

I want to extend my heartfelt thanks to Dr. A. RAJESWARI, Principal, Coimbatore


Institute of Technology, for providing me with the opportunity and resources to pursue this
endeavor.

I am profoundly grateful to Dr. K. SAKTHI MALA, Dean, of Computing, Coimbatore


Institute of Technology, for her continuous encouragement and valuable insights.

I extend my sincere gratitude to Dr. J. SHANA, Head In-charge, Department of


Computing (Artificial Intelligence and Machine Learning), for her mentorship guidance, and
encouragement throughout this project has been instrumental in keeping me on the right track.

I am also thankful to SIVA KB, a Senior software developer who supervised and
mentored me during my internship. His expertise and insights in the field have been invaluable,
and his practical knowledge has enabled me to develop a thorough understanding of industry
standards. His guidance has been instrumental in shaping my skills and has greatly contributed
to the completion of this project

i
SYNOPSIS

This project involves developing AI-powered solutions to enhance business operations,


including a QR code system for component tracking, chatbots for customer support, and an
SQL-querying assistant for data access. These tools improve efficiency, customer
engagement, and decision-making across sales and service processes.

• BEL QR Code System


A web application for efficient component tracking and quality inspection through
QR code generation and scanning. This system stores part details and inspection data,
enhancing traceability and reducing errors in component management.
• E-commerce Chatbot
An AI-powered chatbot that provides personalized product recommendations, real-
time order tracking, and answers frequently asked questions on shipping, returns, and
account management, boosting customer satisfaction and operational efficiency.
• SQL-querying Assistant
Converts natural language queries into SQL commands, enabling non-technical users
to access and visualize data effortlessly. It bridges the gap between complex data
retrieval and everyday business insights, empowering informed decisions.
• Sales Assistant Chatbot
This chatbot manages booking, promotional email marketing, and in-chat payment
processing, providing customers with real-time support and seamless transaction
options to enhance sales engagement and streamline the booking process.

Technologies Used
These applications utilize HTML, CSS, JavaScript (frontend); Node.js(backend); and
MongoDB (database). NLP models power chatbot responses and SQL queries, while libraries
like Pandas handle data visualization. Secure payment APIs are integrated for transactions
within the chat, ensuring a smooth user experience.

ii
CHAPTER I

INTRODUCTION

1.1. ORGANIZATION PROFILE

Overview
Spritle Software is a technology consulting firm specializing in AI-driven solutions to empower
businesses with advanced digital transformation tools.

Core Services

1. Custom AI Solutions
Spritle develops AI systems tailored to individual business needs, including
recommendation engines, predictive analytics, and intelligent automation, designed to
enhance efficiency and decision-making.
2. Conversational AI & Chatbots
Spritle’s AI-driven chatbots handle customer support, personalized recommendations,
and operational automation, enhancing user engagement and satisfaction.
3. Computer Vision
Spritle implements real-time image processing solutions across retail, healthcare, and
manufacturing, enabling functions like visual search and quality control.
4. NLP & Text Analysis
Spritle’s NLP services offer sentiment analysis, text categorization, and content
recommendations, creating a natural user experience and automating text-based
insights.

Industries Served

• E-commerce: Product recommendations, chatbots, and customer insights.


• Healthcare: Diagnostic imaging, patient assistance, and data analysis.
• Finance: Fraud detection, predictive analytics, and customer support.

1
1.2 PROBLEM ANALYSIS

1.2.1 TASK 1: BEL QR Code Component Management System

Goals

• Generate and manage QR codes for component tracking

• Enable efficient quality inspection processes

• Provide automated report generation

• Implement secure data storage and retrieval

• Ensure component traceability throughout the system

Problems in Existing System : Current component management systems rely on manual


tracking, leading to inefficiencies and errors. Paper-based inspection records are difficult to
maintain and retrieve, causing delays in quality control processes. Many systems lack real-time
tracking capabilities and automated reporting features. Component history and inspection data
are often scattered across multiple platforms, making it challenging to maintain comprehensive
records. Additionally, manual data entry increases the risk of errors and inconsistencies in
component documentation.

Proposed Solution: The BEL QR Code System will provide a comprehensive digital solution
featuring QR code-based component tracking, automated inspection processes, and centralized
data management. The web interface will enable QR code generation and scanning, while
component-specific inspection forms will streamline quality control. With automated reporting
and a user-friendly dashboard, the system will ensure efficient tracking, accurate
documentation, and easy access to component information, ultimately replacing manual
processes with a streamlined digital workflow.

1.2.2 TASK 2: ECOM - Product Recommendation Chatbot

Goals

• Provide personalized product recommendations.


• Automate responses to frequently asked customer questions.
• Enable order tracking functionality for user convenience.

2
• Summarize and display product reviews for a quick overview.
• Implement Guardrails to ensure safe and accurate responses.

Problems in Existing System: Current e-commerce customer service models often lack
personalized support, causing customers to search extensively for relevant products. Many
systems cannot automate FAQ responses effectively, leading to repetitive support queries.
Order tracking, when available, often requires navigation through multiple pages, and
customers lack quick access to summarized reviews. Additionally, without appropriate
guardrails, chatbot responses can be inconsistent or off-brand.

Proposed Solution: The product recommendation chatbot will use AI algorithms to tailor
recommendations based on customer preferences and order history. Automated FAQ responses
will be implemented to instantly handle common queries, reducing the need for live support.
Integrating order tracking into the chatbot will allow users to view their order status within the
chat interface. Summarizing product reviews and providing an overall summary will improve
decision-making for customers, while Guardrails will be established to ensure responses are
consistent, secure, and on-brand.

1.2.3 TASK 3: SQL-QUERYING ASSISTANT OF ECOM SALES DATA

Goals

• Provide a dual-interface system that includes a chat interface for user queries and a
plot interface for data visualization.
• Integrate e-commerce data from CSV files for real-time querying and visualization.
• Enable users to add training data and specify SQL parameters, improving query
accuracy.
• Visualize query results in tables and graphs for easy analysis.

Problems in Existing System: Traditional sales data analysis methods often require SQL
knowledge, making data exploration challenging for non-technical users. Visualization is
limited, with only predefined graphs and charts, which restricts deeper analysis. Training data
must often be manually processed before use, making data handling labor-intensive.
Additionally, lack of user feedback on SQL query accuracy can lead to errors in analysis
without corrective measures.

3
Proposed Solution: This system will provide a chat interface where users can input natural
language queries, converting them to SQL commands for querying the e-commerce data. The
Plot Interface will display dynamic visualizations, making data easier to interpret. Users can
directly add training data, define SQL parameters, and confirm question-SQL pairs, enabling
flexible and accurate querying. Error handling features will prompt users to verify the SQL
query, and if incorrect, the system will offer options for manual or automatic adjustments.

TASK 4: SALES AI CHATBOT

Goals

• Act as an automated AI Sales Representative capable of booking appointments and


processing payments.
• Integrate with Stripe for secure, streamlined payment handling.
• Capture and save visitor information as sales leads.
• Provide real-time chat functionality, supporting both manual and automated
interactions.

Problems in Existing System: Sales support systems often require manual intervention,
delaying customer response times. Payment processing is frequently handled through external
sites, which disrupts the sales flow. Lead information is either not captured or not stored in an
accessible manner, limiting follow-up opportunities. Finally, real-time chat systems are often
limited to either fully automated or fully manual, reducing flexibility for sales teams.

Proposed Solution: The AI Sales Chatbot will serve as an automated representative, capable
of booking appointments and handling payments within the chat interface through Stripe
integration, providing a seamless transaction experience. It will capture visitor details and store
them as leads for future follow-ups. Real-time chat functionality will support both manual and
automated modes, allowing flexibility to meet varying customer needs and support levels,
ultimately enhancing the sales experience and boosting lead conversion.

4
CHAPTER II

SYSTEM ANALYSIS

2.1 SYSTEM ENVIRONMENT

2.1.1 SOFTWARE REQUIREMENTS

• Tools:Voiceflow, Airtable, Makeai, ShopifyAPI, WebScraper API tool, PandasAI, VannaAI


API, ChatNVIDIA, LangChain
• Frontend:Next.js 15,Tailwind CSS
• Backend:Node.js & Express.js (server-side framework),Prisma ORM,Neon Database
(PostgreSQL database)
• Real-Time Communication:Pusher (for real-time messaging and updates)
• Payments:Stripe Connect

2.1.2 HARDWARE REQUIREMENTS

• Processor: Intel Core i5


• RAM: 8 GB
• Storage: 500GB SSD

5
CHAPTER III

METHODOLOGY

3.1 TASK 1-QR-BASED ELECTRONIC COMPONENT INSPECTION


MANAGEMENT SYSTEM(POC)

3.1.1 PROBLEM STATEMENT

Bharat Electronics Limited's current component inspection process relies on manual,


paper-based methods, leading to significant operational inefficiencies and quality control risks.
Key challenges include time-consuming documentation, inconsistent inspection standards,
inefficient component tracking, scattered data management, and compliance difficulties. This
outdated system results in potential human errors, delayed reporting, and ineffective decision-
making. The lack of a centralized digital solution hinders quick data analysis, trend
identification, and easy access to historical records. These limitations underscore the urgent
need for a modern, QR code-based digital inspection system to streamline processes,
standardize quality control, and enhance overall operational efficiency.

3.1.2 SOFTWARE REQUIREMENTS

Users of the System:

1. Quality Analysts: Perform inspections, enter inspection parameters, and access


classification reports.
2. Inventory Managers: Track and manage components using generated QR codes,
facilitating efficient inventory control.
3. Maintenance Technicians: Use the QR system for quick retrieval of component
details, aiding in maintenance and replacements.
4. Supervisors/Managers: Access reports and historical data for compliance audits,
trend analysis, and decision-making.

6
• User authentication and dashboard page
The BEL's QR-Based Inspection System dashboard page requires secure user
authentication, an intuitive navigation system with a sidebar menu, and two main
functionalities: Generate QR Code and Scan QR Code.

• QR Generator Component
The QR generator component begins with a comprehensive data input form designed to
capture essential details for each component. Users are required to enter the part
number, arrival date (using a date picker), component type (e.g., capacitor, motor,
gear), and purchase order number. Each input field is rigorously validated, with
specific error messages displayed for any invalid entries. All fields are mandatory and
include validations to ensure the date is correctly formatted and doesn’t permit future
dates.
• QR Code Generation
Once the data is entered, the system generates a unique QR code that encodes all input
data into a single format. The QR generator validates all fields before QR generation,
ensuring accuracy. Additionally, the system prevents duplicate QR codes from being
generated for the same part number, thus avoiding redundancy and errors in the tracking
system.
• Form Validation
The system enforces mandatory field completion and displays error messages for any
invalid inputs. It prevents form submission if any fields are empty ensures that the date
format is valid and doesn’t allow dates set in the future, maintaining data integrity.
• Data Storage
After generation, each QR code, along with its associated data—including part number,
arrival date, component type, and order number—is saved to local storage for future
access. Data persistence across sessions enables users to retrieve previously generated
QR codes, ensuring continuity and ease of access.
• QR Scan Component
The QR scan component displays a table of previously generated QR code data, with
columns for part number and component type, as well as an action button labeled “View
QR” for each entry. Selecting the “View QR” button opens a modal window showing
the corresponding QR code image.

7
• QR Code Viewing and Modal development
Within the modal, a “Scan QR” button initiates a scanning process to retrieve and
display stored details like part number, component type, and order number. This
functionality enables quick access to the stored data linked to each QR code.
• Quality Control and Inspection Report
For quality assurance, a quality analyst can input inspection parameters for each
component. These inputs are compared against standard ranges, with the system
classifying the component as Critical, Major, or Minor based on the results. This
classification report can then be downloaded as an Excel file for record-keeping and
further analysis.

3.1.3 USE CASE DIAGRAM

Figure 3.1 Use Case Model of the QR code generation

8
3.1.4 ARCHITECTURE

Figure 3.2 shows the architecture diagram represents a high-level overview of web
application structure.

Figure 3.2 Architecture diagram of the QR code generation

Sample parameters:

Figure 3.3: Sample parameters for checking the components

9
3.1.5 MODULE DESCRIPTION

• Authentication Module:

• Renders a login form with username and password fields


• Utilizes client-side validation for input fields
• Implements error handling and displays messages for invalid inputs

• QR Generator Component:

• Collects user input from form fields (part number, arrival date, component type,
purchase order number)
• Uses JavaScript to access input values via DOM manipulation
• Structures data into a JavaScript object
• Converts the object into a JSON string using JSON.stringify()
• Uses qrcode.js library to generate a QR code from the JSON string
• Creates a base64-encoded image URL of the QR code
• Renders the QR code by creating an <img> element and setting its src attribute to the
data URL
• Appends the image to a designated container on the webpage

• QR Scan Component:

• Utilizes DataTables library for dynamic, searchable table creation


• Fetches data from the server using AJAX calls
• Implements server-side pagination for efficient data loading
• Renders "View QR" buttons for each table row
• Implements modal functionality using Bootstrap's modal component
• Generates QR code images on-demand using qrcode.js
• Displays QR code in modal when "View QR" button is clicked
• Adds "Scan QR" button to the modal with Bootstrap's button classes
• Integrates HTML5 Webcam API for accessing the device camera
• Uses jsQR library to process video stream and detect QR codes
• Upon successful scan, sends scanned data to the server to retrieve full component details
from MongoDB

10
• Dynamically updates modal content with retrieved details
• Provides form inputs for quality analysts to enter inspection parameters
• Implements client-side validation for entered parameters
• Develops server-side logic to compare parameters with stored ranges and classify
components as Critical, Major, or Minor
• Generates an Excel report with relevant component details and classification results
using ExcelJS
• Implements a download mechanism for the generated Excel file

• Data Flow:

• Client-side JavaScript handles user interactions and initial data display


• AJAX requests send/receive data to/from the server
• Server processes requests, interacts with the database, and sends responses
• ExcelJS generates reports on the server, which are then sent to the client for download

3.1.6 SYSTEM WORKFLOW

Figure 3.4 shows the workflow of the project from generating QR code to scanning to
approve/reject the component

Figure 3.4 System workflow of the project

11
3.1.7 UI DESIGN

Screens 3.1 to 3.7 have the UI design of Scan and generator components
1. LOGIN PAGE

Screen 3.1:Login page


2. DASHBOARD

Screen 3.2:Dashboard page

12
3.QR GENERATOR AND SCAN COMPONENT

Screen 3.3: QR generator details page

Screen 3.4:Details about components

13
Screen 3.5: Scan QR components page

4. INSPECTION PARAMETERS

Screen 3.6:Inspecting the parameters

14
5. EXCEL REPORT

Screen 3.7: Excel report of major/minor defect

15
3.2 TASK 2 ECOM PRODUCT RECOMMENDATION CHATBOT

3.2.1 OBJECTIVE

This project aims to develop a comprehensive AI-powered chatbot solution that enhances
customer experience and support within an e-commerce platform. The chatbot will be an
intelligent assistant capable of providing personalized product recommendations, automating
responses to frequently asked questions, facilitating order tracking, and offering summarized
insights into product reviews for better decision-making. Additionally, robust guardrails will
be implemented to ensure the chatbot operates securely and provides accurate, contextually
appropriate responses, creating a seamless and trustworthy interaction for users.

3.2.2 FUNCTIONAL REQUIREMENTS

Users:

1. Customers
2. Customer Support Team
3. Marketing Team
4. IT and Development Teams
5. Product Management and Analytics Team

• User Interaction and Input

The chatbot will leverage Natural Language Understanding (NLU) to interpret user queries
accurately, allowing customers to interact naturally. It will support product search using
keywords, product names, categories, or specific attributes like price and color. Multi-turn
conversations will enable users to refine their recommendations through an interactive
dialogue. Additionally, session and persistent memory features will allow the chatbot to
remember user preferences within and across sessions, enhancing personalization.

• Product Information Retrieval

The chatbot will provide detailed product information, including price, descriptions, images,
and user reviews to meet customer information needs. It will also display real-time
availability, keeping users informed of in-stock items and estimated delivery updates.

16
Furthermore, the chatbot will offer updated pricing and promotions, ensuring that users
always see the latest deals.

• Cart Integration and Order Status

The chatbot will support seamless cart integration, allowing users to add recommended
items directly to their cart. It will also provide order status updates, including shipping
information and tracking options, making it easy for users to stay updated on their
purchases.

• Feedback and Support

To address customer support needs, the chatbot will include frequently asked questions
(FAQs) and other support resources. It will also provide information for post-purchase
support, such as return policies, warranty details, and contact options for additional
assistance.

• Review Summary Generation

The chatbot will offer a review summarization feature, providing users with concise
insights into product reviews. Through sentiment analysis, it will highlight both positive
and negative feedback and display a rating breakdown. A review tag cloud will visually
represent common themes and insights, allowing users to make informed decisions
quickly.

• Guardrails

To ensure secure and accurate interactions, the chatbot will implement various guardrails.
Input validation will involve sanitizing inputs, handling invalid entries with helpful
feedback, limiting input length to prevent spam or malicious content, and validating data
types. Output filtering and monitoring will ensure that responses are safe and appropriate.
This includes profanity detection, sensitive content blocking, and output throttling to
manage excessive data. Together, these measures will help create a reliable, safe, and
enjoyable experience for all users.

17
3.2.3 USE CASE DIAGRAM

Figure 3.5 to 3.7 have the use case diagrams of the project

• Cart Integration and Order Status

Figure 3.5: Cart and Order Status

• Review Summary Generation

Figure 3.6: Review Summary Generation

• Guardrails

18
Figure 3.7: Guardrail module

3.2.4 DATA PREPARATION

• Web Scraping of Product Data:

Extract product details such as name, description, price, image, tags, and more from a
given e-commerce category page (Superpharm).Handling pagination to collect a specified
number of products from multiple pages and extracting relevant product data using CSS
selectors. Translate the extracted product details into English using the Google Translate API.
Store the extracted and translated product data into a JSON file.

Figure 3.8:Scraped data of products

19
Data description:

Table 3.1:Description of Scraped data

Review dataset:

Figure 3.9 : reviews dataset containing 100 product reviews

20
3.2.5 MODULE DESCRIPTION

• Product Recommendation Module

The product recommendation module is structured around a workflow set up through


VoiceFlow, where product suggestions are provided based on user queries. The
recommendations are dynamically retrieved from Airtable, leveraging a generated formula
that pulls relevant products based on search parameters. The recommendation process
incorporates several key techniques, including query expansion for enhanced relevance,
metadata filtering to narrow down results based on specific attributes, and reranking to
prioritize the most suitable options. Additionally, conversation history is preserved through
VoiceFlow’s ConversationSummary agent, which helps maintain a summary of chat
interactions for more personalized recommendations.

• Order Management and AI Integration Module


This combined module encompasses order updates, tracking, and product data integration
to ensure a cohesive user experience from product recommendation to post-purchase support.
When a customer completes an order, the details of the purchased product are automatically
updated in Airtable via an HTTP request. Each order is assigned a unique order number
that enables precise tracking, allowing users to monitor their order status seamlessly.To
maintain real-time access to product information, the module utilizes the Shopify API to
fetch the latest product data from Shopify. These details are formatted into JSON and
organized using the iterator tool. Through Airtable’s API, ordered products are then
upserted into Airtable, with each order’s date recorded. This integration not only supports
real-time updates for recommendations but also connects product details, order tracking, and
customer data for a streamlined experience across the purchasing journey.

• Automate Chatbot Responses Module (FAQ)


For automating chatbot responses to frequently asked questions, a scraped dataset comprising
common FAQs and their corresponding answers from the website is used. The Falcon-7B
model is loaded with the AutoModelForCausalLM and AutoTokenizer from the Hugging
Face Transformers library. The QLora Configuration is established using the QLoRA
configuration class, with training metrics logged to TensorBoard via the report_to

21
argument. This module enables the chatbot to provide accurate, pre-trained responses to user
inquiries.

• Summarizing Product Reviews Module


The review summarization module is built using the PASS (Perturb-and-Select
Summarizer for Product Reviews) framework, working with a dataset that includes
individual customer reviews for each product. Using a pre-trained T5 model (Text-to-Text
Transfer Transformer), the module fine-tunes the T5 model on review datasets to generate
candidate summaries. These summaries are ranked for coherence using a pairwise classifier,
also based on the T5 model, which evaluates and ranks summaries according to coherence.
The ranking mechanism is further refined by counting the frequency at which each summary
appears as the most coherent in pairwise comparisons.

• Guardrails Module
For robust interaction safety, NeMo Guardrails with Genvoy have been implemented. This
ensures moderated interactions by applying dynamic moderation parameters that adapt to
different user queries. A two-tiered protection approach is used, applying guardrails to both
user inputs and chatbot responses. Content filtering is achieved through in-house classifiers
that detect and block unsafe or inappropriate content, contributing to a secure and trusted user
experience.

22
3.2.6 ACTIVITY DIAGRAM

Figure 3.10: Activity diagram for product recommendation

3.2.7 UI DESIGN

Chatbot UI

Screen 3.8 : Chatbot UI page

23
3.3 TASK 3 SQL-QUERYING ASSISTANT OF ECOM SALES DATA

3.3.1 OBJECTIVE

The objective of the SQL-Querying Assistant for E-commerce Sales Data is to provide a user-
friendly system that enables non-technical users to access, query, and visualize sales data
effectively. Through a dual-interface setup—a Chat Interface for query input and a Plot Interface
for visual data representation—the system empowers users to interact with and analyze sales data
seamlessly. This assistant simplifies data exploration by integrating SQL generation, error
handling, and visualization tools, helping users make data-driven decisions quickly. The assistant
supports users in refining queries, managing data interactions, and generating valuable insights
through visual aids, all while ensuring accuracy and flexibility in SQL query execution.

3.3.2 FUNCTIONAL REQUIREMENTS

Users:

1. Non-Technical Business Users


2. Data Analysts
3. Sales and Marketing Teams
4. IT and Development Teams

• Chat design:

The chat system offers two options for user interaction: a Chat Interface, where users can input
queries through a text box, and a Plot Interface, which displays data visualizations based on
user queries. An integrated CSV file containing e-commerce data enables querying and
visualization within the system. Users can also add training data directly via the interface,
specify DDL, documentation, and SQL queries for data training, and input accurate question-
SQL pairs to ensure precise querying.

• Data Querying and visualisation:

The system generates SQL queries based on user inputs and predefined patterns, fetching
relevant data from a PostgreSQL database to respond to user queries. It visualizes the data using
tables and graphs based on the SQL query results, displaying the generated plots within the Plot
Interface.

24
• Error Handling

•Asks the user to verify the generated SQL query:

•If incorrect, the system provides two options: Manual fix by the user,Automatic fix by the
system

3.3.3 USE CASE DIAGRAM

Figure 3.11: Use Case Diagram for the SQL querying assistant

25
3.3.4 DATABASE DESIGN

Table 3.2: Database design for the project

3.3.5 MODULE DESCRIPTION

• UI Module

The user interface module is divided into two distinct components: the Chat Interface and the
Plot Interface, ensuring a comprehensive yet intuitive user experience.

Core Components:

• Chat Interface: This mode allows users to interact with the AI Assistant to ask sales
data-related questions in natural language. The assistant responds conversationally,
generating SQL queries on the backend based on user input.
• Plot Interface: In the Plot Interface, users can view visual representations of data in
response to their queries, providing an immediate graphical overview of trends and
metrics.

These dual interfaces allow users to switch seamlessly between text-based inquiries and visual
data exploration.

• Data Querying and visualisation:

26
The assistant's conversational logic is powered by advanced language models and a structured
query generation framework. This module utilizes NVIDIA AI’s ChatNVIDIA model
(meta/llama3-70b-instruct) for natural language processing, interpreting user queries and
generating relevant responses.

Core Components:

• LLMChain: This chain from LangChain routes the user’s query through the large
language model, where SQL queries are generated and data responses are interpreted.
It allows for robust conversational interaction and seamless SQL query generation
based on user intent.
• Prompt Templates: To ensure that responses and SQL generation are contextually
relevant, two primary prompt templates are employed:
o Conversational QA Prompt: Generates SQL queries directly from user input,
enabling natural language interaction that yields database-driven answers.
o Modify QA Prompt: Handles cases where data may be unavailable or irrelevant
to the question, offering alternative responses or clarification

Plotting module enhances data presentation by visualizing query results in graphical formats,
aiding in data analysis and interpretation. Matplotlib serves as the primary plotting library,
allowing for flexible and varied visualizations such as bar plots, which represent sales data,
trends, and key metrics effectively.

• Data Flow:

• Pandas and Vanna.ai: Data is retrieved and managed using Pandas, with Vanna.ai
providing integration to directly generate plots from the processed DataFrame.
• Buffering with io.BytesIO: Each generated plot is stored temporarily in a bytes buffer,
facilitating smooth rendering and display within the interface without saving the file
locally.

Customizing Vanna’s Flask API to enable interaction with the Chatbot Assistant, supporting
user queries and enhancing response accuracy. The customized Vanna API integration handles
incoming queries, generating and retrieving the appropriate data for either text-based answers
or visual plots.

27
3.3.6 ACTIVITY DIAGRAM

Figure 3.12 : Activity diagram of SQL querying assistant

28
3.3.7 CHATBOT UI

Screens 3.9 to 3.12 have the UI of the chatbot

Screen 3.9: Chatbot UI SQL query retrieving

Screen 3.10: Plot graph of query

29
Screen 3.11 Training data adding page

Screen 3.12: DDL commands adding page

30
3.4. TASK 4 SALES AI CHATBOT

3.4.1 OBJECTIVE
The objective of the Sales AI Chatbot is to serve as an automated sales representative,
streamlining customer engagement, appointment scheduling, and payment processing.
Designed to operate in real-time, the chatbot can function both automatically and in a hybrid
model where a live representative may take over as needed. Integrating with Stripe, the chatbot
provides a secure and seamless payment solution, allowing customers to complete purchases
or transactions directly within the chat interface. Additionally, it is programmed to capture and
store visitor information, which can then be used to identify potential leads, optimizing sales
funnel effectiveness. By booking appointments and providing personalized responses, the
chatbot not only enhances user experience but also automates essential sales and customer
service functions, improving operational efficiency and conversion rates.

3.4.2 FUNCTIONAL REQUIREMENTS

Users:
1. Customers
2. Sales and Marketing Teams
3. Business Owners
4. Customer Support Agents

• Automated AI Sales Representative

The AI chatbot serves as a virtual sales representative, proficiently managing customer


queries and providing detailed product information. It guides users to the appointment
booking system and securely redirects them to the payment gateway as needed. Additionally,
it can handle a range of inquiries, redirecting complex or highly specific questions to human
agents or business owners upon customer request. This seamless hand-off ensures that
customers receive accurate information and personalized support when needed.

• Appointment Booking and Payment Processing

To streamline scheduling, the chatbot offers a fully integrated appointment booking system
where customers can select from available time slots directly within the chat. This
functionality improves efficiency and the user experience by simplifying the scheduling

31
process. Once an appointment is confirmed, the chatbot facilitates secure payment processing,
creating a single interface for booking and payment to ensure a hassle-free customer journey.

• Stripe Integration for Payments

Through Stripe integration, the chatbot provides secure and reliable payment processing,
assuring customers of safe transactions. The system automatically confirms payments in real-
time, reducing the likelihood of errors and improving transaction speed and convenience.
Stripe's integration ensures that each transaction complies with security standards, offering
customers a trusted payment experience.

• Lead Capture and Email Marketing

During interactions, the chatbot collects visitor information, such as names and email
addresses, which are securely stored for future marketing efforts. This enables business
owners to develop targeted email campaigns based on captured data, enhancing lead
generation and client retention. By capturing contact information, the chatbot supports the
business’s email marketing strategy, allowing for personalized follow-up and engagement.

• Real-Time Chat with Manual and Automated Options

The chatbot provides instant, automated responses to common queries, offering customers
24/7 support. However, if a situation demands human intervention, the system allows a
smooth transition for live agents to join and manage the conversation, ensuring high-quality
service. This flexibility between automation and manual engagement ensures that customers
receive prompt and accurate support at all times, enhancing overall satisfaction.

32
3.4.3 USE CASE DIAGRAM

Automated AI Sales Representative

Figure 3.13: Functional requirements of the Chatbot module

Appointment Booking and Payment Processing

Figure 3.14: Functional requirement of Appointment booking module

33
3.4.4 MODULE DESCRIPTION

1. AI Chatbot Module

• Purpose: Manage user interactions and provide context-aware responses.


• Components:

NLP Engine: Utilizes OpenAI API for natural language understanding.

Response Generator: Formulates responses based on user queries.

Context Management: Tracks conversation history for multi-turn interactions.

• Interactions:

Integrates with Appointment Booking and Lead Management for context-aware responses.

2. Appointment Booking Module

• Purpose: Manages scheduling and appointment bookings.


• Key Components: Calendar Interface: Uses react-calendar for time slot selection.
• Booking Logic: Validates and stores appointment bookings.
• Notifications: Sends booking confirmations via email.
• Interactions:Integrates with Payment Processing for transactions.Guides users via the
AI Chatbot Module for booking.

3. Payment Processing Module

•Purpose: Manages secure payment transactions.

•Key Components:

Stripe Integration: Uses Stripe API for secure payments.

Transaction Management: Handles payment confirmations, failures, and refunds.

Security Compliance: Ensures PCI compliance for secure payment handling.

•Interactions:

34
Linked with Appointment Booking for payment during bookings.

Sends payment status updates to the AI Chatbot Module.

4. Lead Management Module

•Purpose: Captures and stores visitor information as leads.

•Key Components:

Lead Capture Forms: Gathers user info during chatbot interactions.

Database Integration: Uses Neon DB and Prisma ORM to store leads.

Data Management: Provides tools for lead management and export.

•Interactions:

Works with the AI Chatbot Module to capture lead data.

Integrates with Email Marketing for follow-up campaigns.

5 Real-Time Chat Module

Purpose: Provides immediate communication between users and agents.

Key Components:

WebSocket Implementation: Utilizes Socket.io for real-time messaging.

Message History: Stores and retrieves interaction logs for context.

Agent Interface: Dashboard for agents to monitor and manage conversations.

Interactions:

Works with the AI Chatbot Module for automated responses.

Allows manual agent intervention when needed.

35
3.4.5 ACTIVITY DIAGRAM

Figure 3.15: Activity diagram of the Sales assistant

36
3.4.6 UI DESIGN

Screens 3.13 to 3.16 are the UI design of the application

Screen 3.13: Email marketing UI for admin

Screen 3.14: Payment module and appointment module

37
Screen 3.15: Real-time conversation with admin and user

Screen 3.16: Chatbot Training UI

38
CHAPTER IV

IMPLEMENTATION

4.1 PSEUDOCODE

4.1.1 TASK 1

QR Generation module

function scanQRCode() {
const qrURL = currentQRURL; // Use the global variable to get the QR URL
const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');
const img = new Image();

img.crossOrigin = "anonymous";
img.onload = function() {
canvas.width = img.width;
canvas.height = img.height;
context.drawImage(img, 0, 0, canvas.width, canvas.height);

const imageData = context.getImageData(0, 0, canvas.width, canvas.height);


const code = jsQR(imageData.data, imageData.width, imageData.height, {
inversionAttempts: 'dontInvert',
});

39
if (code) {
try {
let qrData = {};
const lines = code.data.split('\n');
lines.forEach(line => {
const [key, value] = line.split(':').map(str => str.trim());
if (key && value) {
qrData[key] = value;
}
});

console.log('Parsed QR Data:', qrData);

if (qrData["Part Number"] && qrData["Arrival Date"] &&


qrData["Component Type"] && qrData["Order Number"]) {
const url = new URL('http://127.0.0.1:5500/view/qr_data.html');
url.searchParams.append('partNumber', qrData['Part Number']);
url.searchParams.append('arrivalDate', qrData['Arrival Date']);
url.searchParams.append('componentType', qrData['Component Type']);
url.searchParams.append('orderNumber', qrData['Order Number']);
window.location.href = url;
} else {
throw new Error('Missing required QR data fields');
}
} catch (e) {
console.error('Failed to parse QR code data:', code.data);
alert('Failed to parse QR code data.');
}
} else {
alert('No QR code found.');
}
};

img.src = qrURL;
}

4.1.2 TASK 2

WEB SCRAPING
def main(category_url, json_filename='superpharm_products.json'):
base_url = 'https://www.superpharm.pl'

selectors = {
'name': 'span.base',
'description': 'div.value',
'detail': 'h2',
'price': 'span.price',

40
'image': 'picture source[type="image/jpeg"]',
'type': 'h1.page-title span.base',
'tags': '.product-tags'
}

category_soup = get_soup(category_url)
product_type = 'N/A'
if category_soup:
type_tag = category_soup.select_one(selectors.get('type', 'h1.page-
title span.base'))
product_type = type_tag.text.strip() if type_tag else 'N/A'

product_urls = get_product_urls(category_url)
all_products = []

for url in product_urls:


full_url = urljoin(base_url, url)
soup = get_soup(full_url)
if soup:
pd = extract_product_data(soup, full_url, base_url, selectors,
product_type)
if pd:
all_products.append(pd)

print(f"Collected {len(all_products)} products.")

if os.path.exists(json_filename):
with open(json_filename, 'r', encoding='utf-8') as input_file:
existing_products = json.load(input_file)
all_products = existing_products + all_products

if all_products:
with open(json_filename, 'w', encoding='utf-8') as output_file:
json.dump(all_products, output_file, ensure_ascii=False, indent=4)
print(f"Saved to '{json_filename}'")

if __name__ == "__main__":
category_url = 'https://www.superpharm.pl/makijaz/makijaz-twarzy.html'
main(category_url)

41
Screen 4.1:Workflow in voiceflow

4.1.3 TASK 3

PLOT GENERATION LOGIC


def plot_data(query):
try:
result = agent.chat(query)
if isinstance(result, pd.DataFrame) and not result.empty:
x_col = None
for col in ['Brand', 'Name', 'Product', 'Category']:
if col in result.columns:
x_col = col
break

if x_col:
result.set_index(x_col, inplace=True)

# Create a plot based on the result DataFrame


fig, ax = plt.subplots()
result.plot(kind='bar', ax=ax)

ax.set_title('Generated Plot for Query')


if x_col:
ax.set_xlabel(x_col)

# Save the plot to a bytes buffer


buf = io.BytesIO()
plt.savefig(buf, format='png')
buf.seek(0)

return buf
else:

42
st.write("The query did not return data suitable for plotting.")
return None
except Exception as e:
st.write(f"Error generating plot: {str(e)}")
return None

SQL QUERY GENERATION LOGIC


def conversational_qa(context, question, sql_query):
answer_prompt = PromptTemplate.from_template(
"""
Role: ECOM AI Assistant
Task: Answer user questions related to sales data based on the provided data
getting from sqlite db inside context.
Company_details: ECOM provides reliable after-sales customer care to global
MNCs in Asia, backed by a dedicated team and strong technical expertise.

EXAMPLE COMPANY DATA LOOKS LIKE THIS:

Columns header:- Alpha Code, Brand, Order Value, Units, Euro

Row data:- 194900491102, Michael Kors, 161, 169, 18659.2

Instructions to follow:
- Answer questions in a humanly conversational manner, don't give direct
answers.
- Your answer should be short and concise.
- Understand SQL query and its result from db to answer user query
correctly.
- If the context does not contain the answer, state that the information
is not available.
- If context is empty, inform the user you can't fetch related data.

use the below real data provided below context to answer user query:
<Context>
Sql query: {sql_query}
Db result: {result}
<Context>

User Question: {question}


Answer: """
)
llm_chain = LLMChain(llm=llm, prompt=answer_prompt, verbose=True)
response = llm_chain.predict(question=question, result=context,
sql_query=sql_query)
return response

VANNA API INTEGRATION


@self.flask_app.route("/api/v0/get_training_data", methods=["GET"])

43
@self.requires_auth
def get_training_data(user: any):
"""
Get all training data
---
parameters:
- name: user
in: query
responses:
200:
schema:
type: object
properties:
type:
type: string
default: df
id:
type: string
default: training_data
df:
type: object
"""
df = vn.get_training_data()

if df is None or len(df) == 0:
return jsonify(
{
"type": "error",
"error": "No training data found. Please add some
training data first.",
}
)

return jsonify(
{
"type": "df",
"id": "training_data",
"df": df.to_json(orient="records"),
}
)

4.1.4 TASK 4

44
AI CHATBOT

APPOINTMENT BOOKING MODULE

PAYMENT PROCESSING

45
LEAD CAPTURING

46
REAL-TIME CHAT FUNCTIONALITY

47
CHAPTER V

TESTING

5.1 TEST CASE AND REPORTS


Tables 5.1 to 5.4 explains the test cases of the tasks

5.1.1- QR-Based Inspection Management System (POC)

Table 5.1: API Endpoint Test Cases

TestCase TestCase Action Expected Actual


No. Description Result Result
1 Test QR Data Send a POST request to Status Code: PASS
Save http://localhost:3000/api/save 200. Response
Endpoint with body { "partNumber": Body:
"PART123", Contains the
"componentType": saved data
"Capacitor", "qrURL": "" } including an
automatically
generated ID.
2 Retrieve All Send a GET request to Status Code: PASS
QR Data http://localhost:3000/api/data 200. Response
Body: Array
of all saved
QR data
objects.

5.1.2 E-commerce Recommendation System

Table 5.2: Edge Case Handling

TestCase No. Objective Test Case Expected Actual Result


Description Result
1 Test the Ask questions The chatbot PASS
chatbot’s that are outside clearly and
response to the chatbot's politely
irrelevant scope indicates the
questions scope of its
responses and
may provide
alternative
responses or
suggestions.
2 Check Ask questions The chatbot PASS
guardrails for that do not should

48
out-of-scope pertain to the gracefully
queries chatbot's decline to
intended use or answer and
knowledge inform the user
base of its response
limitations.

5.1.3 SQL Query Assistant

Table 5.3: Test Cases for AI-Generated SQL Query Evaluation

TestCase No. Objective Test Case Expected Actual Result


Description Result
1 Test AI- Generate and AI-generated PASS
generated test SQL queries are
query queries for syntactically
correctness syntactic and correct and
semantic semantically
accuracy using align with the
the OpenAI intended
Evals question.
framework
with a
synthetic JSON
dataset.
2 Test Output Compare the The results PASS
Accuracy results of the from the AI-
AI-generated generated
query against a query match
predefined the predefined
reference reference
output to results.
ensure
accuracy.
3 Error Handling Log incorrect Errors in query PASS
for SQL Query query results generation are
Issues and apply SQL logged, with
syntax syntax
validation rules validation
to identify and applied to
analyze issues. catch and
address
incorrect
queries.

49
5.1.4 Sales Assistant Chatbot
Table 5.4: API endpoint testing

TestCase No. TestCase Action Expected Actual Result


Description Result
1 Booking Create a Booking is PASS
Creation booking successfully
request created
2 Validates time Select Time slot is PASS
slots available time validated as
slot available
3 Creates Save booking Booking record PASS
booking record details is created in
the database
4 Links customer Associate Customer and PASS
and domain customer and domain are
domain correctly
linked
5 Sends Trigger Customer PASS
confirmation confirmation receives
email/SMS confirmation
notification
6 Overlapping Book an System PASS
bookings overlapping prevents
(Edge) slot overlapping
bookings
7 Past dates Try booking System PASS
(Edge) for a past date restricts
bookings for
past dates
8 Invalid Use an invalid System shows PASS
customer IDs customer ID an error
(Edge) message for
invalid
customer

50
5.2 TEST SCREENSHOTS
Screen 5.1 and Screen 5.2 has Testing Screenshots of task 1

5.2.1 TASK 1

Screen 5.1 : Testing QR Data Save Endpoint

Screen 5.2: Retrieve All QR Data

51
5.2.2 TASK 2
Screens 5.3 and 5.4 has testing screenshots of task 2

Screen 5.3: Testing of integration between Airtable and Shopify

Screen 5.4: Tensorboard logs while training with QLORA Adapter

52
5.2.3 TASK 3

Screens 5.5 and 5.6 have testing screenshots of task 3

Screen 5.5: 25 test samples taken for testing

Screen 5.6: Achieved 80% accuracy

53
5.2.4 TASK 4

Screens 5.7 to 5.10 have testing screenshots of task 4

Screen 5.7: Stripe API connection request

Screen 5.8: Stripe API connection status

54
Screen 5.9: Appointments API connection request

Screen 5.10: Appointment API connection status

55
CONCLUSION

The task involved crafting a helpful AI companion for e-commerce platforms, designed to
enhance the shopping experience for customers by making it more enjoyable and efficient. This
AI assistant provides personalized product recommendations, instantly answers common
questions, and tracks orders to create a seamless and engaging shopping experience. A user-
friendly system was also developed to enable non-technical users to explore and analyze sales
data effortlessly by converting natural language queries into SQL commands and displaying
the results in accessible formats.

A smart sales assistant was also introduced, capable of booking appointments, handling
payments, and capturing lead information while providing real-time chat support. This versatile
AI representative optimizes sales workflows and enhances customer interactions, ultimately
improving conversion rates and customer satisfaction. Various cutting-edge tools and APIs
were integrated to create a powerful, cohesive, and user-friendly system. This project
significantly broadened technical expertise in AI implementation, full-stack development, and
database management, with potential to revolutionize e-commerce and data analysis, making
them more accessible, efficient, and enjoyable for all stakeholders.

56
BIBLIOGRAPHY

Web references:

1. Voiceflow: https://www.voiceflow.com/

2. Airtable: https://www.airtable.com

3. Make AI: https://www.make.com

4. Shopify API: https://shopify.dev/api

5. Web Scraper: https://webscraper.io

6. PandasAI: https://www.pandasai.com

7. VannaAI: https://www.vanna.ai

8. QLORA: https://arxiv.org/abs/2305.14314

9. PASS: Perturb-and-Select Summarizer for Product Reviews.


https://nadavo.github.io/publication/2021-08-01-PASS

10. Pusher: https://pusher.com

57

You might also like