Building Agentic Chatbots with CrewAI

Cover Image for Building Agentic Chatbots with CrewAI
Arfath Ahmed Syed
Arfath Ahmed Syed

Welcome to the world of agentic chatbots—where multiple intelligent agents collaborate to provide smarter, more insightful responses. In this guide, we'll walk through the basics of setting up CrewChat Crew, a multi-agent Conversational AI Chatbot built on the powerful crewAI framework. This project is designed to enable your AI agents to work together on user queries, pooling their expertise to deliver the best possible answers.

What Is CrewChat Crew?

CrewChat Crew is a cutting-edge project that leverages crewAI's robust framework to build chatbots with multiple agents. Each agent is designed to contribute its unique capabilities, collaborating seamlessly to address complex queries and tasks. Whether you're a developer or a researcher exploring collaborative AI, this guide will get you started on building your own agentic chatbot system.

Prerequisites

Before you begin, make sure you have the following ready:

  • Python Version: Python ≥3.10 and <3.13
  • Dependency Manager: This project uses UV for dependency management and package handling, ensuring a seamless setup experience.

Step 1: Setting Up Your Environment

Install UV

First, install UV using pip if you haven't already:

pip install uv

Update Your Hosts File

To prevent any telemetry connection issues, add the following entry to your /etc/hosts file:

127.0.0.1       telemetry.crewai.com

Step 2: Installing the CrewChat Crew Project

Navigate to your project directory and install the necessary dependencies:

crewai install
uv add weaviate-client crewai[tools] fastapi uvicorn rich
cd src

Note: The current code expects a 'Products' collection in your local Weaviate instance. For instructions on setting up Weaviate and the collection, check out the Weaviate-RAG repository.

Step 3: Running Your Agentic Chatbot

Once all dependencies are installed, start your chatbot system by running the following command from the root folder of your project:

uvicorn main:app --reload

This command initializes CrewChat Crew—assembling the AI agents and assigning them tasks based on your configuration. Here's a sample Python code that demonstrates how to set up a simple agent:

from crewai import Agent, Task, Crew

# Define your agents
researcher = Agent(
    role="Research Analyst",
    goal="Uncover the most relevant information about LLMs",
    backstory="You're an AI research expert who specializes in analyzing trends in AI",
    verbose=True
)

writer = Agent(
    role="Technical Writer",
    goal="Create clear, engaging explanations of complex AI concepts",
    backstory="You're a skilled writer who makes complex topics accessible",
    verbose=True
)

# Define your tasks
research_task = Task(
    description="Research the latest developments in Large Language Models",
    agent=researcher
)

writing_task = Task(
    description="Write a comprehensive guide about LLMs based on the research",
    agent=writer
)

# Create your crew
crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, writing_task],
    verbose=2
)

# Start the crew's work
result = crew.kickoff()
print(result)

Wrapping Up

This guide provided a quick-start overview of setting up an agentic chatbot using CrewChat Crew and crewAI. While this content is a placeholder for now, it lays the foundation for building more advanced, collaborative AI systems.

Stay tuned for more in-depth guides and advanced configurations that will help you fully harness the power of crewAI for intelligent, multi-agent chatbots.

Happy coding and enjoy building your AI crew!