-
-
Notifications
You must be signed in to change notification settings - Fork 202
Autoreply and AI
The bot supports two auto-reply mechanisms: keyword-based canned responses (built-in) and AI-powered replies via LLM (optional). Both can be used simultaneously — keyword rules are checked first, and the LLM handles messages that don't match any rule.
Define question-answer pairs in config.yaml. When a user message contains the question text as a substring (case-insensitive), the answer is sent automatically. First matching rule wins.
autoreply:
- question: "install"
answer: "You can install using our [Getting Started guide](https://github.com/bostrot/telegram-support-bot/wiki/Getting-started)"
- question: "refund policy"
answer: "We offer full refunds within 30 days of purchase."
- question: "hours"
answer: "Our support team is available Monday-Friday, 9am-5pm CET."| User Message | Matches Rule | Reason |
|---|---|---|
| "How do I install?" | question: "install" |
Case-insensitive substring match |
| "What's your refund policy?" | question: "refund policy" |
Substring match |
| "Do you offer refunds?" | no match | Neither "refund" nor "policy" appear together as defined rule |
| "Installation help please" | question: "install" |
Matches substring "install" (case-insensitive) |
When an auto-reply is sent, the following occurs based on your settings:
- If
show_auto_replied: true, a notification is forwarded to the staff chat indicating which canned response was triggered - The user sees the reply with a signature from
language.automatedReplyAuthor(default: "BottyBot") - Users can provide feedback via the
doesntHelp("This does not help") button on auto-replies
Auto-reply answers support MarkdownV2 formatting. Use \n for line breaks within YAML strings:
autoreply:
- question: "pricing"
answer: "*Plans:* \n- Basic: $9/mo \n- Pro: $19/mo \n- Enterprise: Contact us"Enable AI-generated responses using any LiteLLM-compatible proxy. The bot sends the user's message along with your custom knowledge base to the LLM, which generates a contextually appropriate reply.
use_llm: true # Enable LLM auto-replies
llm_api_key: 'sk-your-api-key-here' # API key for your provider
llm_base_url: 'https://api.openai.com/v1' # LiteLLM proxy or direct API endpoint
llm_model: 'gpt-4o' # Model identifier
llm_knowledge: | # Custom knowledge base (multi-line string)
Company ABC provides cloud hosting services.
Pricing tiers:
- Starter: $5/mo, 10GB storage, shared resources
- Business: $20/mo, 100GB storage, dedicated CPU
- Enterprise: Custom pricing
Support hours: Mon-Fri 9am-6pm CET.
Refund policy: Full refund within first 14 days. No refunds after that.| Setting | Type | Description |
|---|---|---|
use_llm |
boolean | Enable/disable LLM auto-replies. Automatically sets show_auto_replied: true. |
llm_api_key |
string | API key for the LLM provider or LiteLLM proxy |
llm_base_url |
string | Base URL of the LLM endpoint (e.g., OpenAI, Anthropic via LiteLLM) |
llm_model |
string | Model name (e.g., gpt-4o, claude-3-haiku, mistralai/ministral-3b) |
llm_knowledge |
string | Custom knowledge base text injected as context — the LLM uses this to generate company-specific answers |
- User sends a message that doesn't match any keyword autoreply rule
- Bot constructs a prompt with: user's question +
llm_knowledgecontent + system instructions - Sends request to the configured LLM endpoint
- Returns the generated response to the user, attributed as an automated reply
LiteLLM allows you to use any LLM provider through a single API-compatible endpoint. To set up:
- Install and run LiteLLM proxy
- Configure it with your preferred LLM providers (OpenAI, Anthropic, Mistral, etc.)
- Point
llm_base_urlto your LiteLLM instance:
use_llm: true
llm_api_key: 'your-litellm-proxy-key'
llm_base_url: 'http://localhost:4000/v1' # Your LiteLLM proxy URL
llm_model: 'claude-3-haiku' # Any model your proxy routes to- Keep
llm_knowledgeconcise and well-structured — the LLM works best with clear, organized information - Use bullet points and sections for readability
- Include pricing, policies, common procedures, and product details
- Update when your company's information changes — no bot restart required (config is read on startup)
If the LLM request fails (network error, rate limit, invalid key), the message falls through to normal ticket handling: it gets forwarded to the staff chat as a regular ticket. The user won't see an error — they'll receive a human response instead.
When both are configured, the bot checks in this order:
- Keyword autoreply rules → if matched, send canned answer immediately
-
LLM auto-reply → if no keyword match and
use_llm: true, generate AI response - Normal ticket → if neither applies (or LLM fails), forward to staff group as a regular ticket
This means you can use keyword rules for exact, policy-critical answers (refund terms, legal disclaimers) while letting the LLM handle open-ended questions.
Please tell me if something is missing in this guide or should be added — open an issue on GitHub.
Home · Getting Started · Configuration · Commands · Categories · Auto-reply and AI · Addons · Markdown · Troubleshooting · Upgrading