A RAG consultant for an immigration law firm: what it answers and what it hands to the lawyer
An immigration lawyer in Warsaw was spending hours a day on the same questions. Which documents do I need for a karta pobytu? How long does it take? Her site was a brochure: it brought no leads from Google, and every first message was answered by hand. We rebuilt the site and put a consultant inside it that answers from the firm's own material. Here is the shape of it. The site first The…
A Warsaw-based immigration lawyer was spending excessive amounts of time answering repetitive questions about documents and timelines for karta pobytu. Her existing website provided no search engine traffic and responses were manually generated for each incoming inquiry. The firm rebuilt its website and integrated an AI consultant within it that retrieved relevant information from the law firm's own case files and official documents.
The site was built to prioritize user accessibility, with Next.js 15 and multi-language routing in Russian, Polish, and Ukrainian to accommodate non-Polish speakers. Structured data was implemented to enhance the site's visibility in search results. Instead of a single comprehensive page, separate pages were created for specific inquiries like "karta pobytu Warszawa" or "pobyt stały Polska".
The AI assistant, powered by GPT-4o with retrieval capabilities, was trained on over 200 real cases handled by the law firm and official decision documents. To answer client queries, the assistant first embedded the question, then retrieved relevant chunks from the knowledge base stored in Postgres using pgvector embeddings. The assistant only used the provided context to formulate answers, and if the knowledge base did not contain enough information, it would inform the client that a consultation was needed.
The consultant's primary purpose was to handle standard questions and forward complex cases to the lawyer. After answering the routine part of a client's query, the assistant requested contact information and a brief description of the case, then sent the details directly to the lawyer via Telegram. This streamlined the process, allowing clients to receive immediate answers rather than waiting for hours.
The implementation proved successful, with the site ranking in Google's top 10 for numerous commercial queries related to immigration in Poland. The AI assistant handled approximately 80% of first contacts, reducing wait times for clients. The firm's rating improved to 4.9 stars from 312 clients. A notable side effect was that ChatGPT began recommending the site to users asking about immigration assistance in Warsaw.
For anyone looking to build a similar AI assistant, the key takeaway is that the knowledge base is the most critical component. Real cases and official documents are far superior to any well-crafted prompts. The assistant should be programmed to acknowledge when it doesn't have an answer and facilitate a consultation with the lawyer. The information to be sent to the lawyer should be concise, containing the contact details, country, relevant topic, and the client's question.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.