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.
- .NET 9.0
- Telegram.Bot (v22)
- Mindee OCR SDK
- QuestPDF for PDF generation
- HuggingFace API
- Microsoft.Extensions.Hosting & Dependency Injection
Services/
: Core services likeBotService
,OcrService
,ChatService
,PolicyService
Models/
: Domain models likeConversationState
,ExtractedData
Options/
: Configuration binding classesInterfaces/
: Service abstractions
- User sends
/start
- Bot asks for passport photo
- Bot saves uploaded passport
- Bot requests vehicle ID image
- Bot saves image
- OCR is performed via Mindee
- Data is displayed with a
Yes/No
inline keyboard
- Yes: Proceed to pricing
- No: Ask for resubmission
- Bot generates and sends PDF policy
- Bot continues with GPT-style chat
Implements IHostedService
, orchestrates Telegram updates and bot flow.
In-memory per-user state tracking.
Uses Mindee API to extract user identity from passport images.
Generates PDF policies using QuestPDF.
Handles user Q&A via Hugging Face.
"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"
}
services.AddSingleton<IConversationStore, ConversationStore>();
services.AddSingleton<IPolicyService, PolicyService>();
services.AddSingleton<IOcrService, OcrService>();
services.AddHttpClient<IChatService, ChatService>();
services.AddHostedService<BotService>();
- AI, OCR, and Telegram errors are logged via
ILogger
- Graceful fallback messages are returned to the user
This bot uses QuestPDF and Mindee SDK which require compliance with their respective licenses.
Developed by Viktor Bilonizhka using modern .NET practices and Telegram.Bot SDK 22.