Overview
Before your bot can interact with OpenChat, it must be registered and initialized. This process requires cycles payment and involves several configuration steps.Bot Status Lifecycle
Your bot progresses through three states during initialization:#NotInitialized- Initial state, bot has not been registered#Initializing- Registration in progress with OpenChat#Initialized- Bot successfully registered and ready to use
Prerequisites
Canister Cycles
When deploying to mainnet, create your canister with sufficient cycles:- 0.5 XDR for canister instantiation
- 10 XDR for OpenChat bot registration fee
- 1.5 XDR for operational costs
Admin Access
Add your principal as a custodian to access management endpoints:Initializing Your Bot
Call initBot with bot name
The
initBot function registers your canister as an OpenChat bot. You can provide an optional display name:The bot name must be unique across OpenChat. Choose a descriptive, memorable name.
Understand the registration process
When you call The bot status transitions to
initBot, the following occurs:#Initializing and exactly 10 XDR in cycles is attached to the registration call.Handle registration responses
The registration can return several responses:Success Response:Error Responses:Your bot status reverts to
#NotInitialized on error, allowing retry.Configuring Bot Avatar
After initialization, you can set a custom avatar for your bot:Avatar Requirements
- Maximum size: 800KB (819,200 bytes)
- Supported formats: Any format supported by OpenChat
- Must be uploaded to OpenChat storage first
Setting Avatar
Avatar Type Definition
Error Handling
Always check for errors during initialization:Common Issues
Insufficient Cycles
Problem:#InsufficientCyclesProvided error
Solution: Top up your canister with more cycles:
Bot Already Registered
Problem:#AlreadyRegistered error
Solution: Your bot is already registered. The status should be #Initialized. If you need to reset, you must use a new canister.
Name Conflict
Problem: Bot name is already taken Solution: Choose a different, unique bot name.Next Steps
Once your bot is initialized:Join Communities
Learn how to join groups and channels
Send Messages
Start sending messages to OpenChat