How Bots Respond
Ever wondered what happens when someone messages your bot? Here's the behind-the-scenes journey of how BotGami processes a message and sends a response.
The Journey of a Message
When a user sends something to your bot:
All of this happens in milliseconds — users get instant responses!
Step by Step
1. User Sends Message
The user types something in Telegram and hits send.
2. Telegram Delivers It
Telegram forwards the message to BotGami.
3. Finding the Right Flow
BotGami looks at all your triggers to find a match:
- Does any trigger match this message?
- If yes, run that flow
- If no, no response (unless you have a catch-all)
4. Running the Flow
The flow executes step by step:
- Each node runs in order
- Data passes along the wires
- Decisions are made at condition nodes
5. Sending the Response
When the flow hits an action node (like Send Message), BotGami sends it to Telegram, which shows it to the user.
What Can Trigger a Flow?
| Trigger Type | Example |
|---|---|
| Commands | /start, /help, /menu |
| Any text | User sends "hello" |
| Buttons | User clicks an inline button |
| Photos | User sends a picture |
| Location | User shares their location |
You can have different flows for each type!
When Multiple Triggers Match
If a message could match multiple triggers, BotGami runs the first match.
Arrange your triggers from most specific to least specific:
/start(exact command)- Messages containing "help"
- Any text message (catch-all)
Waiting for Replies
Some flows need to pause and wait for the user to respond:
How Waiting Works
- The "Ask Question" node sends a message and pauses
- BotGami remembers where the flow stopped
- When the user replies, the flow resumes from that point
- The answer is automatically captured and available
This is how you build multi-step conversations!
Priority System
BotGami runs certain flows before others:
| Priority | What Runs | When |
|---|---|---|
| First | Guard flows | Every message — for access control |
| Second | Your triggers | When they match |
Guards are special flows that check things like "is this user allowed to use the bot?" before regular flows run.
Error Handling
What happens when something goes wrong?
- Minor issues — The flow tries to continue
- Major issues — The flow stops and logs an error
- Error handler — If you've set one up, it catches errors
You can add an "On Error" trigger to handle problems gracefully and send the user a helpful message instead of silence.
Response Times
How fast does BotGami respond?
| Flow Type | Typical Time |
|---|---|
| Simple greeting | < 100ms |
| Database lookup | 100-300ms |
| External API call | 200-1000ms |
Users experience responses as "instant" for most flows.
Testing Your Flows
The best way to understand how your bot responds is to test it:
- Save your flow
- Open Telegram
- Message your bot
- See what happens!
There's no substitute for real testing with a real Telegram conversation.
Next Steps
- Node Reference → — Learn all the node types
- Variables → — Store and use data