A WhatsApp agent powered by CDP (Coinbase Developer Platform) Agentkit and LangChain, enabling intelligent conversations and blockchain interactions through WhatsApp.
- WhatsApp message handling via webhooks
- AI-powered responses using GPT-4
- Blockchain interaction capabilities on Polygon network
- Autonomous and interactive chat modes
- Secure key management and environment configuration
- Python 3.10+
- Poetry for dependency management
- CDP API Key
- OpenAI API Key
- WhatsApp Business API credentials:
- Access Token
- App ID
- Phone Number ID
- Verify Token (for webhook setup)
- Clone the repository and install dependencies:
poetry install
- Configure environment variables:
Create a
.env
file in the project root with the following:
CDP_API_KEY_NAME=your_key_name
CDP_API_KEY_PRIVATE_KEY=your_private_key
OPENAI_API_KEY=your_openai_key
NETWORK_ID=polygon-mainnet
ACCESS_TOKEN=your_whatsapp_token
APP_ID=your_app_id
PHONE_NUMBER_ID=your_phone_number_id
VERIFY_TOKEN=your_verify_token
VERSION=v17.0
Website to get Token for your whatsapp: https://developers.facebook.com/apps/476470498862977/whatsapp-business/wa-dev-console/?business_id=613685664604834
- Set up webhook endpoint:
- Install and configure ngrok for local development
- Start ngrok to expose your local server:
ngrok http 5000
- Use the ngrok URL in the Meta Developer Portal for webhook configuration
open another terminal
pip install cdp-sdk
- Start the WhatsApp Agent:
python whatsapp_bot.py
Open your Whatsapp to test out your agent!
Run the test suite to verify API configurations:
python -m pytest
Individual tests can be run for specific components:
test_whatsapp.py
: WhatsApp API connectiontest_openai.py
: OpenAI API integrationtest_cdp.py
: CDP configuration
- Ensure all environment variables are properly set
- Verify webhook URL is correctly configured in Meta Developer Portal
- Check ngrok tunnel is active and webhook URL is up to date
- Confirm Python version compatibility (3.10+)
This project is licensed under the MIT License - see the LICENSE file for details.