AI Chat Guide
How to use and develop the AI chat features in the TRAST Telegram bot.
Overview
The TRAST AI chat is an integrated assistant in the Telegram bot, designed to answer questions about the TRAST platform, projects, tokens, trust scores, and general Web3 topics. It leverages LLM (OpenAI) and has access to the TRAST database for entity lookups.
User Guide
How to Start AI Chat
Private chat: Tap the "AI Chat" button in the main menu or send a message directly.
Group chat: Use the "AI Chat" button; the bot will prompt you to continue in private for privacy and better experience.
Deep link: Use
/start ai
to jump directly to AI chat.
What You Can Ask
"What is vote staking?"
"Tell me about [project name]"
"How do I verify my account?"
"Show trending projects"
"Explain trust scores"
Features
Memory: The AI remembers your previous questions and context for a more natural conversation.
Entity search: Ask about any project, token, or user; the AI will fetch and explain data from the TRAST database.
Help: Ask "What can you help me with?" or tap the help button for guidance.
Button-based navigation: All actions are available via Telegram buttons—no commands needed.
Developer Guide
Architecture
Handler:
ai_chat.py
manages the AI chat flow and user interaction.Service:
LLMService
handles communication with OpenAI API.Memory:
ConversationMemory
stores user-specific context in the database.Entity access: The AI can call database functions to fetch project, token, or user data.
Key Flows
Start AI chat: User taps button or sends message → handler initializes session → memory loaded → LLM called → response sent.
Entity lookup: User asks about an entity → handler parses intent → database queried → result formatted and sent.
Memory update: Each user message and AI response is stored for context.
Group redirect: If AI chat is started in a group, the bot sends a private chat link.
Environment
Requires
OPENAI_API_KEY
for LLM integration.
Roadmap
More database functions (e.g., project rating, reviews)
Scam detection integration
Voice and image support
Multi-language support
Related Docs
Last updated