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
- Cloning the Repository: The first step involves cloning the WhatsApp MCP repository using the
git clonecommand followed by the repository URL. This downloads the necessary files to your local machine.- Example:
git clone <repository_url>
- Example:
- Navigating to the WhatsApp Bridge Folder: After cloning, navigate to the
WhatsApp bridgefolder within the cloned directory. This folder contains the necessary files to connect to WhatsApp. - 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
- Example:
- Running the WhatsApp Bridge: Execute the
main.gofile using thego runcommand. This starts the WhatsApp bridge, which will prompt you to sign in using a QR code.- Example:
go run main.go
- Example:
- 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
- Installing Required Packages: Open a new terminal and install the necessary Python packages using
pip. These includePen AI agents,MCP, and optionallygradiofor a user interface.- Example:
pip install Pen AI agents lm MCP gradio
- Example:
- 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>
- Example:
- Creating the
app.pyFile: Create a Python file namedapp.py(or any other name) to define your AI agents. - Importing Necessary Modules: Import the
agentandMCPmodules from thepraise and AI agentspackage.- Example:
from praise_and_AI_agents import agent, MCP
- Example:
- 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")
- Example:
- Running the Code: Execute the
app.pyfile using thepythoncommand. This will run the AI agent and send a message to the specified WhatsApp contact.- Example:
python app.py
- Example:
Creating Multi-Agent Systems
- Defining Multiple Agents: Create multiple agents, each with its own specific task and MCP tool. For example, an Airbnb agent and a WhatsApp agent.
- 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)
- Example:
Integrating Olama and Grock
- 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.
- Pull a Llama model using
- 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)
- 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.
- Initializing Gradio Interface: Use the
gradio.Interfaceclass 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()
- Example:
- 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
- Example:
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.





