Skip to content

The Car Insurance Telegram Bot is an interactive chatbot designed to guide users through the process of submitting personal documents, extracting essential information via OCR, confirming the details, and issuing a car insurance policy. It integrates with third-party services such as Mindee for OCR and Hugging Face for AI assistance

License

Notifications You must be signed in to change notification settings

zabavb/Car-Insurance-telegram-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bot Logo

Car Insurance Telegram Bot

🖥️ Overview

The Car Insurance Telegram Bot is an interactive chatbot designed to guide users through the process of submitting personal documents (passport and vehicle ID), extracting essential information via OCR, confirming the details, and issuing a car insurance policy. It integrates with third-party services such as Mindee for OCR and Hugging Face for AI assistants.



🧱 Technologies Used

  • .NET 9.0
  • Telegram.Bot (v22)
  • Mindee OCR SDK
  • QuestPDF for PDF generation
  • HuggingFace API
  • Microsoft.Extensions.Hosting & Dependency Injection

🛠️ Project Structure

  • Services/: Core services like BotService, OcrService, ChatService, PolicyService
  • Models/: Domain models like ConversationState, ExtractedData
  • Options/: Configuration binding classes
  • Interfaces/: Service abstractions

🚦 Bot Workflow

1. Start Command

  • User sends /start
  • Bot asks for passport photo

2. Passport Upload

  • Bot saves uploaded passport
  • Bot requests vehicle ID image

3. Vehicle Document Upload

  • Bot saves image
  • OCR is performed via Mindee
  • Data is displayed with a Yes/No inline keyboard

4. User Confirms Data

  • Yes: Proceed to pricing
  • No: Ask for resubmission

5. User Accepts Price

  • Bot generates and sends PDF policy

6. AI Assistant

  • Bot continues with GPT-style chat

🗝️ Key Services

BotService

Implements IHostedService, orchestrates Telegram updates and bot flow.

ConversationStore

In-memory per-user state tracking.

OcrService

Uses Mindee API to extract user identity from passport images.

PolicyService

Generates PDF policies using QuestPDF.

ChatService

Handles user Q&A via Hugging Face.


⚙️ Configuration

"Telegram": {
    "BotToken": "YOUR_BOT_TOKEN_HERE"
  },
  "Mindee": {
    "ApiKey": "YOUR_MINDEE_API_KEY"
  },
  "HuggingFace": {
    "ApiUrl": "https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta",
    "ApiToken": "YOUR_HF_API_TOKEN"
  }

💉 Dependency Injection


services.AddSingleton<IConversationStore, ConversationStore>();
services.AddSingleton<IPolicyService, PolicyService>();
services.AddSingleton<IOcrService, OcrService>();
services.AddHttpClient<IChatService, ChatService>();
services.AddHostedService<BotService>();

❎ Error Handling

  • AI, OCR, and Telegram errors are logged via ILogger
  • Graceful fallback messages are returned to the user

📃 License

This bot uses QuestPDF and Mindee SDK which require compliance with their respective licenses.


🤝 Author & Credits

Developed by Viktor Bilonizhka using modern .NET practices and Telegram.Bot SDK 22.

About

The Car Insurance Telegram Bot is an interactive chatbot designed to guide users through the process of submitting personal documents, extracting essential information via OCR, confirming the details, and issuing a car insurance policy. It integrates with third-party services such as Mindee for OCR and Hugging Face for AI assistance

Topics

Resources

License

Stars

Watchers

Forks