- Open Telegram and search for "@BotFather"
- Start a chat with BotFather and send
/newbot - Follow the prompts:
- Enter a name for your bot
- Enter a username for your bot (must end in 'bot')
- BotFather will give you a token like this:
123456789:ABCdefGHIjklmNOPQrstUVwxyz - Copy this token to your .env file
Note: Keep your token secure! Anyone with your token can control your bot.
- Copy .env.example to .env
- Fill in your Telegram Bot Token in .env
- setup your venv:
python3 -m venv bot-venv - activate your venv:
source bot-venv/bin/activate - Install requirements:
pip install -r requirements.txt - Run the iAgent on port 5000:
docker run -d -p 5000:5000 -e OPENAI_API_KEY="$OPENAI_API_KEY" -v $(pwd)/agents_config.yaml:/app/agents_config.yaml --name injective-agent injectivelabs/iagent - In the terminal, run the bot:
python bot.py
- bot.py: Main Telegram bot logic
- agent_client.py: Interface for interacting with the iAgent
The bot integrates with Injective's iAgent for position analysis. To set up:
-
Clone the iAgent repository:
git clone https://github.com/InjectiveLabs/iAgent.git -
Add your OpenAI API key to .env:
OPENAI_API_KEY=your_openai_api_key_here -
Create a hello_main agent on mainnet:
# Create agents_config.yaml echo "hello_main: network: mainnet" > agents_config.yaml # Run iAgent and create a new agent cd iAgent python quickstart.py # In the quickstart CLI, enter these commands: # switch_network mainnet # create_agent hello_main # The agent's private key and address will be displayed - copy these to your agents_config.yaml
-
Run the iAgent Docker container:
cd iAgent docker build -t injective-agent . docker run -d -p 5000:5000 \ -e OPENAI_API_KEY="$OPENAI_API_KEY" \ -v $(pwd)/agents_config.yaml:/app/agents_config.yaml \ --name injective-agent \ injective-agent
-
Or you can run the prebuilt image:
docker run -d -p 5000:5000 \ -e OPENAI_API_KEY="$OPENAI_API_KEY" \ -v $(pwd)/agents_config.yaml:/app/agents_config.yaml \ --name injective-agent \ ghcr.io/injectivelabs/iagent:latest
-
Verify the container is running:
docker ps | grep injective-agent -
Verify the agent is working properly:
curl -X POST http://localhost:5000/chat \ -H "Content-Type: application/json" \ -d '{"message":"Hello, how are you?", "session_id":"test", "agent_id":"hello_main", "agent_key":"YOUR_PRIVATE_KEY_HERE", "environment":"mainnet"}'
⚠️ Security Warning: Keep your private keys secure! Never commit agents_config.yaml to Git.
Once set up, users can analyze their positions by clicking the "Analyze with iAgent" button in the positions view.