Transforming Customer Care: An Introduction to DTDL's Autonomous Assistant
![https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jd961gj6uzdsfitk5vev.gif https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jd961gj6uzdsfitk5vev.gif](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jd961gj6uzdsfitk5vev.gif)
1. About this blog
Hello, and welcome to the first blog in my DTDL-CustomerCare Series! In this post, I’ll introduce the overall concept and architecture in more depth. But first, let me share how this project began.
The idea of developing a chatbot for the customer care department came to me during some discussions with my current client, who expressed interest in this area. I started brainstorming and planning, but due to a busy few months both professionally and personally, I couldn’t dedicate enough time to it.
Recently, I heard about the Microsoft Developers AI Learning Hackathon, which focuses on “Learning to build AI apps with Azure Cosmos DB.”
![](https://media1.giphy.com/media/v1.Y2lkPTc5MGI3NjExdzY1enJrbjYyNXdycW81YXh4MzhjNDhuYTNhaXh5em4yNnh6NzJlZCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/QxZ0nbcVgMlPlnfZos/giphy.webp)
This sparked my enthusiasm again, and I decided to bring my idea to life.
Before we dive into the challenges we’re addressing and the architecture’s details, here are the key takeaways from this series:
- Familiarity with building AI apps using Azure Cosmos DB 🚀
- How to perform data ingestion with Azure Document Intelligence Service 📄
- Working with Langchain agents 🤖
- Understanding function calling concepts 🧠
- Using completion and embedding models with Azure OpenAI 🔍
Stay tuned as we delve into each of these components in the upcoming posts!
2. Problem statement
Lately, many clients have shown a keen interest in exploring the capabilities of LLMs/SLMs by addressing various challenges. This sparked a discussion with my current client about enhancing operational efficiency in the customer care department. However, other priorities soon took precedence, and the project was put on hold. It wasn’t until I recently heard about a hackathon focused on AI solutions that my desire to tackle this challenge was reignited.
I chose customer service as my problem statement because it’s something many of us can easily relate to. My idea is to build a smart, autonomous assistant that can handle customer queries, such as answering FAQs, and intelligently respond to questions about past orders without the need for long waits or multiple transfers. A key focus was ensuring this assistant could verify users and provide personalized information securely.
![](https://media0.giphy.com/media/v1.Y2lkPTc5MGI3NjExc3B0dmxuYmx0djh0ZXRibHE1bm9pdnB4cGVnZnU1aXdpZTQ5Z3R1dyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/3rgXBBaVvhPXk3NSnK/giphy.webp)
Imagine a customer needing to check the status of their last order. With our assistant, they could simply input their query, receive an OTP on their phone, and verify their identity securely. The assistant would then fetch the details from the database and provide the information instantly. No more waiting on hold, no more frustration.
3. Solution
I wanted to tackle this challenge by leveraging LangChain Agent to build an autonomous solution with minimal human intervention. The core idea behind agents is to use a language model to determine a sequence of actions to take, unlike traditional chains where the sequence is hardcoded. LangChain Agents act as reasoning engines, deciding which actions to take and in what order, making the system both flexible and intelligent. For instance, if a customer asks about their last order, the agent can simultaneously initiate OTP authentication, query the database for order details, and handle any additional requests in the proper sequence. This ensures that each task is executed efficiently and accurately.
“In the movie “The Matrix,” Agent Smith famously says, “Human beings are a disease, a cancer of this planet. You are a plague, and we are the cure.”
I believe that is where we are heading these days with multi agents taking over”
![](https://media4.giphy.com/media/v1.Y2lkPTc5MGI3NjExNjgxMTd5ZmlvZDMxYWxkNDBsOTl0aXhvaXdhZnE3OGZrN3hzaWV6MCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/OS0HFk7Fmkdqw/giphy.webp)
Bringing this idea to life was not an easy task. It required seamlessly integrating various technologies. We used OTP authentication for secure user verification, Twilio API to send OTPs, and Azure Cosmos DB to store and verify customer information. The challenge was to make this process smooth and autonomous, ensuring customers received quick and accurate responses without compromising security. We utilized Azure Cosmos DB for MongoDB vCore’s vector search capability to retrieve relevant documents when a customer asks a query.
We set up two vector indexes: one for retrieving relevant product information from our product collection and another based on FAQs. Using Azure Document Intelligence Service, we retrieved information from existing FAQ PDFs, created a data ingestor to chunk the data, and generated embeddings in our database.
This approach transforms customer service by creating a smart, autonomous assistant that operates with high efficiency and minimal delay. The integration of LangChain Agent with Azure Cosmos DB, Twilio API, and Azure Document Intelligence Service ensures a robust, secure, and intelligent solution for handling customer queries.
Through the DTDL-CustomerCare series, we will explore the architecture and components that make this innovative solution possible. From data ingestion and AI integration to secure authentication and function calling, we’ll delve into each aspect in detail. Our goal is to share insights and knowledge that can help others build similar solutions, ultimately enhancing the customer service experience for everyone.
3. Architecture
![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jd961gj6uzdsfitk5vev.gif)
4. Data Flow
Document Intelligence Process
The idea behind this process was to scrape the website or generate some potential dummy FAQs related to Telekom services using ChatGPT. I then compiled all the possible FAQs into a PDF.
- First, I analyzed the PDF using the Azure Document Intelligence Studio and found that the Layout model was the best fit for this case.
- Next, I created a Data Ingestor using an Azure Function HTTP trigger to upload the file and extract relevant information with the Azure Document Intelligence service client.
- The content was then semantically chunked based on their headings and stored as separate chunks in Azure CosmosDB for MongoDB vCore, within a collection called “KnowledgeBase.”
A separate blog detailing how to create this will be provided in the next blog of this series.
General query flow
FAQ Query Flow
- For general queries, the query is transformed into an embedding format using the embedding Ada model.
- The query is then subjected to a vector search on the FAQ collection, which we chunked and stored in our Azure CosmosDB for Mongo vCore during our earlier process.
- We retrieve the top k relevant documents from this search and provide them to the LLM.
- Finally, the LLM responds to the customer.
Products Query Flow
- If the query pertains to product information, it is transformed into an embedding format and a vector search is performed on the Products collection.
- We retrieve the top k relevant documents from this search and provide them to the LLM.
- Finally, the LLM responds to the customer.
Past order query flow
- If the query is customer-specific, we start by obtaining the phone number via the agent.
- We then generate an OTP and store it in the database.
- The generated OTP is sent to the customer via the Twilio SMS API.
- The customer is prompted to input the OTP for verification.
- The customer inputs the OTP.
- We verify the OTP against the database and, upon successful verification, fetch the customer-related information.
- Once the information is retrieved, it is added to the LLM context.
- Finally, the LLM responds to the past order or customer-specific query.
5. Source code
6. Live URL
https://dghx6mmczrmj4mk-web.azurewebsites.net/
CAUTION : If the site is slow, it is due to the serverless infrastructure used for this application.