ad
ad

OpenAI's Swarm Tutorial: Build a Multi-Agent Customer Service Bot ?

Education


Introduction

In this article, we'll explore the new AI agent framework by OpenAI called Schwam. This framework was released recently and has quickly gained popularity, becoming one of the most sought-after libraries with over 13,000 stars on GitHub. We'll use Schwam to develop a real-life customer service chatbot that operates as a sales agent for a company called Build Fast with AI.

Overview of the Project

We're setting out to build a sales agent that can respond to user inquiries regarding two primary services: training courses and consulting services. The sales agent will handle user queries, routing them to either the course agent or the consulting agent based on the nature of the inquiry. Each of these agents will have specific functions; for instance, the course agent can offer promo codes, and the consulting agent can facilitate sending emails to users.

Part 1: Creating the Simple Sales Agent

We'll begin by establishing a simple sales agent. First, you'll need to install the Schwam library and load your OpenAI API key as environment variables.

The initial setup of the sales agent includes a system prompt defining its role: "You are a sales agent for Build Fast with AI, a company that provides AI solutions and training to businesses." The agent is instructed to respond with "I don't know" if it cannot provide specific information.

Example Interactions

  1. User Inquiry: "Who are you?"

    • Sales Agent Response: "I am a sales agent for Build Fast with AI, a company that specializes in AI solutions."
  2. User Inquiry: "How long is the generative course?"

    • Sales Agent Response: "I don't know the specific duration of the generative course."
  3. User Inquiry: "Who do I reach out to for consulting services?"

    • Sales Agent Response: "You can reach out to the sales or consulting team."

Part 2: Expanding to a Multi-Agent Setup

Now, we’ll enhance our sales agent by adding two new agents: the Boot Camp Agent and the Consulting Agent. Each agent will possess specific information about their respective services.

  • Boot Camp Agent: Will include details such as course content and duration.
  • Consulting Agent: Will provide information about consulting services and include an email contact.

We'll build a transfer function for each agent, allowing the sales agent to route queries accordingly.

Upgraded Interactions

  1. User Inquiry: "How long is the generative boot camp?"

    • Sales Agent Response: "The generative boot camp is a 6-week intensive program."
  2. User Inquiry: "Whom do I reach out to for consulting?"

Part 3: Implementing Functions for Enhanced Interaction

Finally, we’ll introduce functionality to our agents. We will define two functions:

  • Give Promo Code: This function allows the Boot Camp Agent to provide a promo code to the user.
  • Send Email: This function helps the Consulting Agent create an email response for users requesting more information.

When a user asks for a discount code or requests assistance via email, the respective agent will invoke these functions seamlessly.

Example Functionality:

  1. User Inquiry: "Can I get a discount code for the boot camp?"

    • Sales Agent Response: (Via Boot Camp Agent Function) "Here’s your discount code: SAVE20."
  2. User Inquiry: "Can you send me details for consulting?"

    • Sales Agent forms an email: "Here’s an email drafted for you outlining consulting services."

Conclusion

Through this tutorial, we successfully created a multi-agent customer service bot using OpenAI's Schwam framework. The framework allows easy integration of various agents and functions, enhancing the user experience. The code and documentation are available for you to explore and create your own agents.

Thank you for following along, and we hope to see you building with Schwam soon!


Keywords


FAQ

Q1: What is Schwam?
A1: Schwam is an AI agent framework developed by OpenAI designed for creating multi-agent systems that can handle customer service tasks.

Q2: What are the main components of the chatbot we built?
A2: The chatbot consists of a sales agent, a boot camp agent, and a consulting agent. Each agent has specific capabilities and functions.

Q3: How can I add more functions to my agents?
A3: You can define functions like "give promo code" or "send email" and integrate them into the respective agents for enhanced interactions.

Q4: Where can I find the code used in this tutorial?
A4: The code and relevant documentation will be shared in the comments or linked for easy access.

Q5: Is Schwam easy to integrate with OpenAI's API?
A5: Yes, Schwam is designed to work seamlessly with OpenAI's API, allowing for easy setup and configuration.