Multi AI Agent System for Customer Support Automation using CrewAI

Share it with your senior IT friends and colleagues
Reading Time: 4 minutes

Previously we built many multi-AI Agent systems for debate, to customize a resume and content creation automation.

In this tutorial, we will build a Multi AI Agent System for Customer Support Automation.

We will build 2 Agents

  • Support Agent
  • Quality Assurance Agent

In this Multi AI Agent System, the Quality assurance agent can delegate work to the Support Agent. We will be using the CrewAI framework to do it.

Let us dive in.

If you are an IT professional and looking to learn AI and Gen AI in a simple language, check out the most up-to-date course – https://www.aimletc.com/online-instructor-led-ai-llm-coaching-for-it-technical-professionals/

Multi AI Agent System for Customer Support Automation using CrewAI

You can find the code notebook here – https://github.com/tayaln/Multi-AI-Agent-for-Customer-Support-Automation

To use it, download and then upload it to your Google Drive and open it as a Google Colab file.

So, what is the logic?

We will create 2 Agents

  1. Support Agent will access the ScrapeWebsite tool to access the information present on your website. It will then answer the user query based on the information it has scrapped. Finally, it will pass the answer to the Quality assurance agent.
  2. The quality assurance agent will take the answer from the support agent and check whether the answer is correct and appropriate. If the answer is not acceptable then it can delegate the task back to the support agent.

Let’s see everything in the code.

Pre-requisite

– An Open Mind to learn new things

– OpenAI API Key (Please note – OpenAI API keys are paid)

Code Walkthrough – Multi AI Agent System for Customer Support

Step 1 – Install CrewAI, Crewai_tools and langchain_community

CrewAI_tools is installed to access the tool and langchain_community is needed to access any 3rd part (here we will be accessing OpenAI models using Langchain)

Step 2 – Import Agent, Task and Crew from CrewAI

Agent is to define the agents

Task is to allocate what task the agent would be performing

Crew is to orchestrate the Multi AI Agent system

Also, add the OpenAI API key and specify the model as GPT 3.5 turbo (You can use another model as well)

Step 3 – Define both Agents by assigning a role, goal and backstory.

With allow_delegation we can enable the agent to delegate the task or not.

We do not want support_agent to delegate the task and hence we make it False

Step 4 – Import tools from crewai_tools

Tools are the external applications that Agents can access to perform their tasks. We are importing 3 tools.

SerperDevTool is to access Google Search

ScrapeWebsiteTool is to scrape the content of a given URL

WebsiteSearchTool is to search the website

Step 5 – Define the scraping tool by assigning the website URL we want the Agent to scrape.

So, we want the Agent to scrape the content first from the webpage using this tool and then answer the user query from that content.

Step 6 – Define the task for both the agents

Task is the work Agent is supposed to do. For defining the task, we first add a description of the task.

We will specify the expected outcome for an agent to understand the end objective.

We will then assign the tool and add the agent.

Similarly, we will define a task for a Quality assurance agent

Step 7 – Now let us combine everything and create a “crew”

Add both agents to “agents” and add both tasks.

Verbose = 2 enables us to see how the agents are thinking.

With Memory=true, we will be giving agents memory to store any information.

Step 8 – Let us pass the customer information and see how the Agent executes the task

Here the most important is how the agent goes about its job. Check how the agent is thinking and working.

Step 9 – Display the result

Hope you liked the tutorial. If you have any queries, feel free to reach out to me on LinkedIn – https://www.linkedin.com/in/nikhileshtayal/

The most up-to-date AI + LLM Coaching

In case you are looking to learn AI + Gen AI in an instructor-led live class environment, check out these courses

Happy learning!

Share it with your senior IT friends and colleagues
Nikhilesh Tayal
Nikhilesh Tayal
Articles: 75