A Bun-based Node.js service that continuously listens for XMTP messages and processes them through the Bitte AI API. a
- Real-time XMTP Integration: Continuously listens for new XMTP messages
- Bitte AI Processing: Routes messages through Bitte AI agents for intelligent responses
- Automatic Error Handling: Handles errors gracefully and sends fallback responses
- Key Generation Utility: Script to generate wallet and encryption keys for setup
- XMTP Message Processing: Real-time automated response to XMTP messages
- AI Agent Proxy: Bridge between XMTP and Bitte AI agents
- Continuous Service: Long-running service for persistent message handling
- Bun (v1.0+)
- Node.js v20+
-
Install Dependencies:
bun install
-
Generate Keys (Optional, for first-time setup):
bun scripts/gen-keys.ts
This will create or append to a
.env
file in your project directory with generatedWALLET_KEY
andENCRYPTION_KEY
. You may need to manually add the other required variables (see below). -
Configure Environment Variables: Create a
.env
file in the project root with the following variables:WALLET_KEY=your_wallet_private_key ENCRYPTION_KEY=your_encryption_key BITTE_API_KEY=your_bitte_api_key BITTE_AGENT_ID=your_bitte_agent_id XMTP_ENV=dev # or 'production', 'staging', etc. (as required)
WALLET_KEY
: EVM private key (hex string, with or without 0x prefix)ENCRYPTION_KEY
: 32-byte hex string for local DB encryptionBITTE_API_KEY
: Your Bitte API key (get from Bitte platform)BITTE_AGENT_ID
: The agent ID to route messages to (e.g.coingecko-ai.vercel.app
)XMTP_ENV
: XMTP environment (dev
,production
, etc.)
-
Run the Service:
bun start
or for development:
bun dev
bun start
/bun dev
: Start the XMTP message listener (production/development)bun scripts/gen-keys.ts
: Generate wallet and encryption keys and append to.env
- XMTP Setup: Creates an XMTP client using your wallet and encryption key, and syncs conversations
- Message Streaming: Listens for new messages via XMTP's streaming API
- Message Processing: For each incoming message, checks sender and content type, then processes
- AI Response: Sends the message to the configured Bitte AI agent and receives a response
- Reply: Sends the AI response back to the XMTP conversation
- Error Handling: Logs errors and sends a fallback message if processing fails
This service is designed to run as a long-running process. You can deploy it to:
- VPS or dedicated server
- Docker container
- Cloud services like Railway, Fly.io, or DigitalOcean App Platform
- Check Environment Variables: Ensure all required env vars are set in your
.env
file - Key Generation: Use
bun scripts/gen-keys.ts
to generate keys if you don't have them - Monitor Logs: Check console output for detailed execution info
- API Errors: If you see errors from Bitte API, check your API key and agent ID
- Restart on Errors: The service will log errors and continue running, but you may need to restart if persistent issues occur
- This project uses Bun as the runtime. All scripts and commands assume Bun is installed.
- The
.env.example
file can be used as a template for your environment variables. - For more details on XMTP, see the included
XMTP_docs.md
.