
AskKSA is an AI assistant I built to help people in Saudi Arabia, especially expatriates, to understand quickly and complete government tasks like Iqama, visa and Absher services by asking questions in simple English or Urdu, using semantic search over a curated Absher knowledge base and a modern LLM to turn that raw information into clear, step by step answers inside an easy Streamlit chat interface. The underlying vector database is refreshed periodically via an offline ingestion pipeline, and the app includes safety prompts, disclaimers, and scope limits to guide users to treat it as an informational assistant—not an official government authority.
AskKSA is an AI-powered assistant designed to help expatriates and residents of Saudi Arabia navigate government services, including Iqama, visas, fines, and Absher. The assistant simplifies complex processes, provides guidance in English and Urdu, and offers accurate, step-by-step answers to frequently asked questions.
AskKSA is a comprehensive solution for expatriates living in Saudi Arabia. It tackles common challenges, such as understanding Iqama renewal processes, using Absher services, and finding reliable information on Saudi government portals. With a focus on user-friendly interaction and bilingual support, AskKSA ensures that users can access crucial government information quickly and in their preferred language.
While there are various systems available to navigate government services in Saudi Arabia, they often require users to visit multiple websites and rely on outdated or fragmented data. Existing tools may not support bilingual users, and many don’t provide contextual guidance. AskKSA fills these gaps by consolidating essential government services into a single platform with multilingual support, ensuring expatriates have access to reliable, up-to-date information through a user-friendly interface.
AskKSA uses a combination of modern technologies to deliver accurate answers:
Embedding Model (BGE-M3): The system converts user queries into a vector representation using advanced sentence transformers. This helps in better understanding the semantic meaning of the questions.
embed_model = SentenceTransformer(EMBED_MODEL_NAME) query_embedding = embed_model.encode([query], convert_to_numpy=True, normalize_embeddings=True)
Vector Database Retrieval (Chroma + BGE-M3): All documents are pre-chunked, embedded with the same BGE-M3 model, and stored in a persistent Chroma vector database. At query time, AskKSA performs a semantic similarity search to find the most relevant chunks.
client = chromadb.PersistentClient(path=VECTOR_DB_DIR) collection = client.get_collection(name="publications") results = collection.query( query_embeddings=query_embedding.astype("float32"), n_results=5, ) docs = results["documents"][0] metadatas = results["metadatas"][0]
Google Gemini 2.5: The assistant feeds the retrieved chunks (with titles and source URLs) into Google Gemini 2.5, which generates a final answer. The system prompt instructs the model to use only the provided context and to state that it is unsure when the information is missing or unclear.
response = client.models.generate_content( model=DEFAULT_MODEL_NAME, contents=gemini_messages, ) return response.text
Multilingual Support: AskKSA supports both English and Urdu, providing localized responses based on the user's input language. A simple language detector checks if the query contains Urdu characters and selects the appropriate language rule.
LANG_RULE_URDU = "Always answer in **Urdu using Urdu script** (the user asked in Urdu)." LANG_RULE_EN = "Always answer in **English** (the user asked in English)."

Scraped and processed content from reliable expat resources (such as Life in Saudi Arabia) and other public information about Saudi government procedures.
Frontmatter metadata (for example, title, source_url, and scraped_at) stored directly in each markdown file, so each chunk keeps track of its origin.
Streamlit Framework: The front-end is built using Streamlit, providing a responsive and modern user interface.
import streamlit as st st.set_page_config(page_title="AskKSA Chatbot", page_icon="🇸🇦")
Chroma Vector Database: A persistent Chroma collection stores precomputed embeddings and metadata, enabling fast semantic retrieval over the curated content.
import chromadb client = chromadb.PersistentClient(path=VECTOR_DB_DIR) collection = client.get_collection(name="publications")
Sentence-Transformers (BAAI/bge-m3): These embeddings are used for semantic understanding and query matching.
from sentence_transformers import SentenceTransformer embed_model = SentenceTransformer(EMBED_MODEL_NAME)
Google Gemini 2.5: For language processing and generating coherent answers, AskKSA uses Google’s Gemini 2.5 model. The API key is managed securely via Streamlit secrets and environment variables.
import genai client = genai.Client(api_key=st.secrets.get("GOOGLE_API_KEY"))
User Input: The user asks a question in either English or Urdu.
typed_input = st.chat_input("Ask your question about Iqama / visas / Absher...")
Language Detection: The system detects the language of the query and processes it accordingly.
def is_urdu_text(text: str) -> bool: return bool(re.search(r"[\u0600-\u06FF]", text))
Data Retrieval: The query is embedded with BGE-M3 and sent to the Chroma collection, which returns the top-k most relevant chunks and their metadata.
retrieved = retrieve(query, embed_model, collection, k=5)
Answer Generation: Google Gemini processes the retrieved information and generates a contextual answer. The system prompt explicitly instructs the model to rely only on the retrieved context and to say “I’m not sure” if the answer is not clearly present.
reply = llm_chat(messages)
Feedback: After receiving the answer, the user can provide feedback on whether it was helpful, which helps improve the system.
st.session_state.feedback.append( {"question": user_input, "answer": answer, "label": "helpful"} )
The application is built on a modular architecture:
Data Layer:
Processing Layer:
Interface Layer:

AskKSA significantly improves the user experience for expatriates. The integration of multilingual support and semantic search not only makes the tool more efficient but also bridges the language barrier for many users. This is especially important given that expatriates often struggle to navigate government portals in Arabic.

AskKSA has a measurable impact on expatriates' daily lives by saving time and reducing frustration when interacting with government systems. The feedback system also helps continuously improve the service, ensuring it meets users' needs and expectations.
AskKSA is designed as an informational assistant, not an official Saudi government service or a legal advisor. The interface and system prompt both remind users to verify essential details (such as fines, deadlines, or residency status) directly on the relevant government portals.
The knowledge base is updated via an offline ingestion pipeline: I periodically re-scrape the curated sources, clean and re-chunk the content, re-embed it with BGE-M3, and rebuild the Chroma vector database. This keeps query-time performance fast while allowing the underlying data to be refreshed when policies change.
To keep the system safe and within scope, AskKSA focuses only on Saudi government services (Iqama, visas, Absher, fines, etc.), avoids answering clearly off-topic or abusive questions, and instructs the LLM to rely only on retrieved context rather than inventing new rules or procedures.
AskKSA still has a few real limits:
Most importantly, AskKSA is not an official government system and does not provide legal representation or individualized legal advice. It should be treated as a navigation and explanation tool, not as a final authority. For time-sensitive or high-impact decisions (for example, visa overstay fines, residency violations, or dispute resolution), users should double-check all answers directly on the official portals or with qualified professionals before acting.
AskKSA simplifies the often confusing, complex processes involved in Saudi government services, offering clear, bilingual support for expatriates and residents. By combining powerful technologies like BGE-M3 embeddings, a vector database, and Gemini 2.5 with an intuitive Streamlit interface, AskKSA provides a practical RAG-based solution that saves time and reduces the stress of navigating government systems. Whether you need to check the status of your Iqama or understand a specific Absher procedure, AskKSA helps you find and interpret the relevant information more easily—while still encouraging you to verify critical steps on official channels.