Skip to content

About

Telegram bot for buying car insurance: document OCR with Mindee, LLM replies via Groq (.NET 8, Docker)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

🚗 Car Insurance Bot

A Telegram bot that walks a user through buying a car insurance policy. It reads the user's documents from photos with Mindee (OCR / document AI), talks to the user through an LLM (Groq, model openai/gpt-oss-20b by default) and issues a policy at a fixed price.

How it works

The conversation is a simple state machine (Models/BotState.cs), kept in memory per chat:

  1. /start — the bot introduces itself and asks for a photo of the passport.
  2. The photo is sent to Mindee; the extracted data is shown to the user for confirmation (Yes / No).
  3. The bot asks for a photo of the vehicle registration document and confirms the extracted data the same way.
  4. The bot quotes the fixed price — 100 USD — and asks the user to accept it.
  5. After acceptance the LLM generates the final insurance policy message.

If the user answers No, the bot asks for a better photo (or explains that the price is fixed). Every bot reply is generated by the LLM from a short prompt, so the wording is natural and varies.

Tech stack

  • .NET 8 (ASP.NET Core host with a BackgroundService for long polling)
  • Telegram.Bot
  • Mindee .NET SDK — passport and vehicle document extraction
  • Groq API (OpenAI-compatible chat/completions) via HttpClient
  • Dependency injection with interfaces for every service (IMindeeService, IGroqService, ISessionService)
  • Docker (multi-stage build)

Project structure

Models/
  BotState.cs                    – steps of the conversation
  UserSession.cs                 – per-chat state and extracted data
Services/
  TelegramBotHostedService.cs    – receives updates and drives the state machine
  MindeeService.cs               – document recognition
  GroqService.cs                 – LLM replies and the final policy text
  InMemorySessionService.cs      – session storage
Program.cs                       – configuration check and DI registration

Configuration

The bot needs three keys. Never commit real keys — appsettings.json contains only placeholders. Pass them as environment variables (the __ separator maps to BotConfiguration:...):

Variable Where to get it
BotConfiguration__BotToken @BotFather in Telegram
BotConfiguration__MindeeApiKey platform.mindee.com
BotConfiguration__GroqApiKey console.groq.com

Optionally, BotConfiguration__GroqModel selects another Groq model. The Mindee model IDs for the passport and vehicle documents are set in Services/MindeeService.cs.

Running

Locally (.NET 8 SDK):

export BotConfiguration__BotToken="..."
export BotConfiguration__MindeeApiKey="..."
export BotConfiguration__GroqApiKey="..."
dotnet run

With Docker:

docker build -t car-insurance-bot .
docker run --rm \
  -e BotConfiguration__BotToken="..." \
  -e BotConfiguration__MindeeApiKey="..." \
  -e BotConfiguration__GroqApiKey="..." \
  car-insurance-bot

Limitations

  • Sessions are stored in memory, so they are lost when the bot restarts.
  • The price is fixed and no real payment is processed — this is a demo / test-task project.

About

Telegram bot for buying car insurance: document OCR with Mindee, LLM replies via Groq (.NET 8, Docker)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages