How an AI-powered VK bot with RAG solves business problems
A typical VK bot built on handlers and regex breaks when a user writes "I want red for 5000" or "send payment link" — it crashes with an unhandled exception. An LLM with an RAG pipeline solves this: GPT-4 understands intent, ChromaDB returns relevant products, and vkbottle handles events without losses. For over 5 years, we have deployed such bots for 30+ projects — from ticket sales to technical support. Natural Language Processing (NLP) using Natasha and spaCy libraries accurately extracts entities and intents.
How to design an RAG pipeline for a VK bot
We collect the community's dialog history, identify the top 10 intents (order, return, status). We design the RAG pipeline: which documents to index, how to chunk text, which embedding model to use (e.g., intfloat/multilingual-e5-large). We use chunking techniques — fixed size of 512 tokens with 128 overlap. According to VK API documentation, Callback events are transmitted in JSON format.
Stack selection: from pilot to production
The primary VK API is Callback (webhook) with the vkbottle library. For AI — LangChain with OpenAI or Mistral provider. Vector DB — ChromaDB (in-memory for pilot) or Qdrant (for production with millions of vectors). We fine-tune the model via LoRA if answer accuracy is below 85%. For NLP, we use Natasha (NER) and spaCy libraries.
Developing handlers and integrating with VK
We set up a FastAPI server with endpoints for VK Callback, integrate LangChain into handlers. Below is a minimal template:
from vkbottle import Bot, Message from vkbottle.bot import BotLabeler bot = Bot(token=VK_TOKEN) labeler = BotLabeler() @labeler.message() async def handle_message(message: Message): user_response = await ai_handler.process(message.text, user_id=message.from_id) await message.answer(user_response) bot.labeler.load(labeler) bot.run_forever() Testing and deployment
We target p95 latency < 2 sec, load testing up to 100 RPS. Deploy on Kubernetes with autoscaling based on GPU utilization. After launch, we monitor with W&B, fine-tune prompts based on user feedback. Automatic A/B test on 10% of traffic allows comparing accuracy and satisfaction metrics.
Why stack choice affects total cost of ownership?
Compare two approaches:
| Component | Budget (initial) | Production (scalable) |
|---|---|---|
| Model | GPT-4o mini (cheaper) | Fine-tuned Mistral on custom data |
| Vector DB | ChromaDB (in-process) | Qdrant with sharding |
| Infrastructure | 1 server 16 vCPU, 64 GB RAM | Kubernetes + GPU nodes (T4) |
| RAG pipeline | LangChain default | LangChain + self-querying retriever |
For up to 10,000 users per month, the budget option suffices. When growing to 100,000, the production stack pays off due to lower latency and fewer escalations. For example, fine-tuned Mistral is 40% more accurate than base GPT-4o mini on specialized queries, and Qdrant is 3x faster than ChromaDB at 100k vectors.
Metrics comparison before and after implementation
Real results from one project (financial consulting)
| Metric | Before | After RAG bot | Change |
|---|---|---|---|
| Operator response time | 15 min | 5 sec | -97% |
| Escalations to human | 100% | 12% | -88% |
| Conversion to lead | 18% | 42% | +133% |
What's included in the turnkey solution
- Architecture documentation (ER diagrams, RAG sequence diagrams)
- Repository with CI/CD (GitHub Actions, Docker, Helm)
- VK community setup: Callback API, keyboards, carousels
- Operator training: how to change prompts, add new documents to knowledge base
- 3-month warranty: bug fixes, model fine-tuning
Contact us — we'll estimate your project in 1 day. We'll send a demo bot with your data. Get a consultation on your scenario — we'll tell you if an AI chatbot is right for your business.
What does VK Mini Apps integration bring?
If you need an interface with an order form, appointment calendar, or payment — we use VK Mini Apps (React + VK Bridge). The bot invokes the Mini App via a button, the Mini App returns the result via postMessage. We did this for a dental clinic: GPT answers questions, Mini App shows available slots and accepts VK Pay payments.
from vkbottle_types.objects import MessagesKeyboard, MessagesKeyboardButton keyboard = MessagesKeyboard( one_time=True, buttons=[[ {"action": {"type": "text", "label": "Order"}}, {"action": {"type": "text", "label": "Information"}}, ]] ) Marketing campaigns: legal and effective
VK allows sending messages only to those who first wrote to the bot or subscribed to the newsletter. Open rate for such messages is 30-50% (higher than email). We use interest-based segmentation: for a user who asked about a specific product, we send a personalized offer after 3 days via Messaging API. No spam — every dialog with consent.
10+ years of experience in VK bot development, certified AI engineers. Get a consultation.







