WhatsApp MCP AI Agents: Build AI Team That Reports Directly to You

Mervin PraisonAbout 5 min readApr 2, 2025Watch original
THE SUMMARYAI-generated

Key Concepts

WhatsApp MCP AI agents, AI teams, Collaborative AI agents, Realtime status updates, Agent orchestration, Local execution, OpenAI API, Olama integration, Grock integration, User interface (Gradio), MCP tools, WhatsApp bridge, Pen AI agents, LLM (Language Model).

Setting up the WhatsApp Connector

  1. Cloning the Repository: The first step involves cloning the WhatsApp MCP repository using the git clone command followed by the repository URL. This downloads the necessary files to your local machine.
    • Example: git clone <repository_url>
  2. Navigating to the WhatsApp Bridge Folder: After cloning, navigate to the WhatsApp bridge folder within the cloned directory. This folder contains the necessary files to connect to WhatsApp.
  3. Installing Go: The WhatsApp bridge requires Go to be installed. Use a package manager like brew (for macOS) to install Go.
    • Example: brew install Go
  4. Running the WhatsApp Bridge: Execute the main.go file using the go run command. This starts the WhatsApp bridge, which will prompt you to sign in using a QR code.
    • Example: go run main.go
  5. Scanning the QR Code: Use your WhatsApp mobile app to scan the QR code displayed in the terminal. This authenticates your WhatsApp account with the bridge. Keep this process running in the terminal.

Creating AI Agents

  1. Installing Required Packages: Open a new terminal and install the necessary Python packages using pip. These include Pen AI agents, MCP, and optionally gradio for a user interface.
    • Example: pip install Pen AI agents lm MCP gradio
  2. Exporting OpenAI API Key: Export your OpenAI API key as an environment variable. This allows the AI agents to access OpenAI's models.
    • Example: export OPENAI_API_KEY=<your_api_key>
  3. Creating the app.py File: Create a Python file named app.py (or any other name) to define your AI agents.
  4. Importing Necessary Modules: Import the agent and MCP modules from the praise and AI agents package.
    • Example: from praise_and_AI_agents import agent, MCP
  5. Defining the WhatsApp Agent: Create an agent that uses the WhatsApp MCP tool to send messages. This involves specifying the LLM (e.g., gpt4-mini), the WhatsApp MCP path, and the recipient.
    • Example:
      whatsapp_agent = agent(
          llm="gpt4-mini",
          tools=[MCP(path="<path_to_whatsapp_mcp>")],
          instruction="WhatsApp agent"
      )
      whatsapp_agent.start("Hello to Mvin Prison")
      
  6. Running the Code: Execute the app.py file using the python command. This will run the AI agent and send a message to the specified WhatsApp contact.
    • Example: python app.py

Creating Multi-Agent Systems

  1. Defining Multiple Agents: Create multiple agents, each with its own specific task and MCP tool. For example, an Airbnb agent and a WhatsApp agent.
  2. Orchestrating Agent Collaboration: Use the agent.start() method to initiate the agents and define how they should work together. The output of one agent can be used as the input for another.
    • Example:
      airbnb_agent = agent(
          llm="gpt4-mini",
          tools=[MCP(path="<path_to_airbnb_mcp>")],
          instruction="Airbnb booking agent"
      )
      whatsapp_agent = agent(
          llm="gpt4-mini",
          tools=[MCP(path="<path_to_whatsapp_mcp>")],
          instruction="WhatsApp agent"
      )
      airbnb_agent.start("Search for apartments in Paris for two nights on Airbnb")
      whatsapp_agent.start(airbnb_agent.output)
      

Integrating Olama and Grock

  1. Olama Integration:
    • Pull a Llama model using olama pull llama3:2b.
    • Specify the tool to use and required parameters (recipient, message) in the agent definition.
  2. Grock Integration:
    • Generate an API key from the Grock dev console.
    • Export the Grock API key as an environment variable: export GROCK_API_KEY=<your_grock_api_key>.
    • Specify the Grock model in the LLM parameter of the agent definition.

Setting up the User Interface (Gradio)

  1. Defining the User Interface Function: Create a function that takes user input and uses the AI agents to process it. This function should return the output to be displayed in the user interface.
  2. Initializing Gradio Interface: Use the gradio.Interface class to create a user interface for the AI agents. Specify the input and output types, as well as the function to be called when the user submits input.
    • Example:
      import gradio as gr
      
      def search_airbnb(query):
          airbnb_agent.start(query)
          whatsapp_agent.start(airbnb_agent.output)
          return airbnb_agent.output
      
      iface = gr.Interface(
          fn=search_airbnb,
          inputs="text",
          outputs="text",
          title="AI Airbnb Search Agent",
          description="Enter your search query for Airbnb apartments."
      )
      iface.launch()
      
  3. Launching the User Interface: Run the Python file containing the Gradio interface. This will launch a web server that you can access in your browser.
    • Example: python whatsapp_agents_ui.py

Key Arguments and Perspectives

  • Opportunity in WhatsApp Automation: The video emphasizes the significant opportunity in automating tasks using AI agents within WhatsApp, citing high open rates (98%) and click-through rates (60%) compared to email (21% open rate, 3% click-through rate).
  • Shift from Single Agents to AI Teams: The video advocates for a shift from traditional single AI agents to collaborative AI teams that can provide realtime updates and seamless handoffs.
  • Empowering AI Managers: The video positions the user as an AI manager who receives realtime updates and manages AI teams, rather than constantly checking dashboards.

Data and Statistics

  • WhatsApp Usage: 50 million+ businesses using WhatsApp, 3 billion+ active WhatsApp users.
  • WhatsApp Engagement: 98% open rates, 60% click-through rates.
  • Email Engagement: 21% open rates, 3% click-through rates.
  • Message Read Time: 60% of WhatsApp messages are read within 15 minutes.

Synthesis/Conclusion

The video demonstrates how to create and manage AI agents within WhatsApp using the MCP framework and Pen AI agents library. It highlights the potential for automating various tasks, improving customer service, and creating collaborative AI teams. The video provides a step-by-step guide to setting up the necessary tools, creating AI agents, integrating with external services like Olama and Grock, and building a user interface using Gradio. The key takeaway is the shift towards managing AI teams through realtime WhatsApp updates, empowering users to automate complex workflows and improve efficiency.

AI summaries can miss context or contain errors. Check important details against the original video.

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.