DEV Community

sudha M
sudha M

Posted on

Building a WhatsApp AI Assistant with RAG, Semantic Search, and Voice Notes

Introduction

AI assistants are becoming increasingly useful for organisations that need to make large amounts of information easier to access. However, building an assistant that provides reliable answers requires more than connecting a language model to a messaging platform.

The system must understand user questions, retrieve relevant information, generate context-aware responses, and recognise when it should not answer.

This was the challenge behind a project delivered by Obii Kriationzs for a public-interest law firm with an NGO-oriented practice. The goal was to develop a WhatsApp AI assistant that could answer common legal information questions using the firm's own documents and knowledge base.

The solution combines Retrieval-Augmented Generation (RAG), document processing, semantic search, response guardrails, and voice-note support within a WhatsApp-based conversational interface.

Here's a closer look at the architecture and the key components involved.

The Problem with General-Purpose AI Chatbots

A conventional AI chatbot can generate fluent responses, but fluency does not necessarily mean accuracy. When an organisation needs answers based on its own documents, relying solely on a language model's general knowledge creates limitations.

For a legal organisation, these limitations are especially important. Responses must remain consistent with approved reference materials, and questions requiring individual legal attention must be handled appropriately.

The project needed to address several challenges:

  1. Making the firm's existing information searchable and accessible.

  2. Connecting everyday user questions with relevant document passages.

  3. Generating answers based on retrieved information.

  4. Supporting both typed questions and voice messages.

  5. Establishing boundaries for questions outside the assistant's intended scope.
    Allowing the knowledge base to evolve as documents are updated.

To address these requirements, the solution was designed around a retrieval-based architecture rather than a standalone chatbot.

Understanding the Architecture of the WhatsApp AI Assistant

The assistant brings together several components, each responsible for a different part of the workflow.

  1. Document Ingestion Pipeline

The process begins with the firm's existing documents and reference materials.

Before an AI system can retrieve useful information from these sources, the content needs to be prepared. A document ingestion pipeline extracts text and divides it into smaller passages that can be indexed and retrieved independently.

This stage is important because poorly structured content can make relevant information harder to locate.

The objective is to transform existing documents into a format that supports efficient retrieval without losing the context needed to interpret individual passages.

  1. Embeddings and Semantic Search

Once the documents have been processed, the passages are converted into embeddings.

Embeddings are numerical representations of text that help a system identify semantic similarities between different pieces of content. They make it possible to retrieve information based on meaning rather than depending exclusively on exact keyword matches.

Consider a user asking a question in everyday language while the corresponding document describes the same subject using formal terminology. Semantic search can help connect the question with relevant passages despite the difference in wording.

The processed information is stored in a searchable index, allowing the retrieval component to identify potentially useful context when a new question arrives.

The quality of this stage depends on factors such as the quality of the source documents, passage segmentation, embedding representations, and retrieval configuration.

  1. Knowledge Base Organisation

Search technology alone is not enough to build a useful assistant. The information being searched must also be organised and maintained.

For this project, knowledge building involved curating the available material, organising topics, identifying information gaps during testing, and improving how the content was structured.

This step helps ensure that the retrieval system has useful material to work with.

It also provides a practical way to improve the assistant over time. When testing reveals missing or unclear information, the knowledge base can be refined instead of treating every problem as a model issue.

  1. Retrieval-Augmented Generation

Retrieval-Augmented Generation, commonly known as RAG, connects information retrieval with language generation.

Instead of asking a language model to answer a question using only its general knowledge, the system first searches a knowledge base and retrieves relevant passages. These passages are then provided to the model as context for generating a response.

In the WhatsApp AI assistant, the workflow follows three main stages:

Retrieve: Identify relevant information from the firm's indexed documents.

Augment: Combine the retrieved passages with the user's question and the instructions governing the assistant's behaviour.

Generate: Produce a response grounded in the available context.

This architecture helps connect answers to the firm's own knowledge and reduces reliance on unsupported general responses.

However, RAG is not a guarantee of correctness. The retrieval component may return incomplete information, source documents may contain inaccuracies, and the model may still misinterpret the context. Evaluation and appropriate safeguards remain essential.

Supporting Voice Notes Through the Same Workflow

An important feature of the solution is its ability to accept voice notes through WhatsApp.

Not every user is comfortable typing a detailed question, particularly when using a mobile device. Voice interaction offers an alternative that can make the assistant more convenient to use.

The process involves converting an incoming voice note into text and passing the transcribed question through the same retrieval and answer-generation workflow used for typed messages.

The sequence is straightforward:

A user sends a voice note through WhatsApp.

The audio is transcribed into text.

The resulting text is processed as a user question.

The retrieval component searches the knowledge base.

The language model generates a response using the retrieved context and applicable instructions.

The response is delivered through WhatsApp.

Using a common processing pipeline helps maintain consistent retrieval and response controls across text and voice interactions.

The quality of voice transcription also matters. If the transcription misses important words or interprets a legal term incorrectly, the resulting answer may not address the user's original question accurately.

Why Guardrails Matter in Legal AI

In sensitive domains, an AI assistant should not attempt to answer every question simply because it can generate a response.

Legal information can depend on specific facts, jurisdiction, circumstances, and current requirements. A general response may be insufficient when someone needs individual legal advice.

For this reason, guardrails form an important part of the assistant's design.

They help establish the boundaries within which the system should operate, guide responses when relevant information is unavailable, and direct users towards the law firm when a question requires professional attention.

  1. A carefully designed guardrail strategy should consider:

  2. Whether the knowledge base contains relevant information.

  3. Whether the retrieved passages adequately support the proposed answer.

  4. Whether the question falls within the assistant's intended scope.

Whether the situation requires escalation to a human professional.

These controls help reduce the risk of presenting unsupported information as authoritative legal guidance. They should work alongside testing, monitoring, and review rather than being treated as a complete solution to AI errors.

The End-to-End Question Processing Flow

The complete workflow can be understood as a series of connected stages.

User input → Voice transcription, if required → Question processing → Semantic retrieval → Context preparation → Guardrail checks → Answer generation → WhatsApp response

Each stage has a specific responsibility.

The input layer receives the message. The transcription component handles audio. The retrieval layer searches the knowledge base. The language model generates a contextual answer, while the guardrails help enforce the assistant's intended boundaries.

Finally, the response is delivered through the same familiar messaging channel.

This separation of responsibilities makes the overall system easier to understand, test, and maintain.

Maintaining and Updating the Knowledge Base

One advantage of a RAG-based architecture is that the information available to the assistant can be updated without necessarily retraining the underlying language model.

When a document changes or new reference material becomes available, the relevant content can be processed and indexed again.

This gives organisations a practical way to maintain their knowledge sources as information evolves.

However, updates need to be managed carefully. Outdated passages may need to be removed, conflicting documents may require review, and retrieval results should be tested to ensure that revised information is surfaced appropriately.

Knowledge maintenance is therefore an ongoing part of operating a reliable AI assistant, not simply a one-time development task.

What This Architecture Offers Organisations

The project demonstrates how several AI capabilities can work together to make organisational knowledge easier to access.

A WhatsApp AI assistant built around a curated knowledge base can offer:

Accessible interaction: Users can submit questions through a familiar messaging application.

Flexible communication: Both text messages and voice notes are supported.

Context-based responses: The language model receives relevant passages from the organisation's own information.

Maintainable knowledge: Documents can be updated and re-indexed as requirements change.

Controlled behaviour: Guardrails help define response boundaries and identify when human assistance is necessary.

Support for routine enquiries: Common information requests can be handled through a consistent workflow, potentially reducing repetitive work for staff.

The practical results depend on implementation quality, the completeness of the knowledge base, and how effectively the system handles real-world questions.

Lessons from Building a Knowledge-Based AI Assistant

This project highlights several important considerations for teams developing AI applications.

First, the quality of the knowledge base matters as much as the choice of language model. An assistant cannot reliably retrieve information that is missing, poorly structured, or outdated.

Second, retrieval quality deserves careful attention. The most relevant passages must be available to the model before it can produce a useful context-based answer.

Third, voice interaction introduces additional processing requirements. Transcription errors can affect every stage that follows.

Finally, safety controls must be designed around the intended use case. In legal and other sensitive professional settings, the system needs clear boundaries and a reliable path to human assistance.

These principles apply beyond legal services. Similar architectures can support internal knowledge systems, customer support assistants, and other applications that need to generate answers from organisation-specific information.

At Obii Kriationzs, we develop AI-powered assistants and automation solutions designed around business requirements and existing knowledge sources.

From conversational interfaces to retrieval-based applications, effective AI implementation requires the right combination of data preparation, search, language generation, integration, and safeguards.

The WhatsApp AI assistant project illustrates how these components can be brought together to make organisational information more accessible while keeping responses grounded in an established knowledge base.

Building a useful AI assistant is not just about generating natural-sounding answers. It is about retrieving relevant information, applying appropriate controls, and delivering responses through a channel that people can use comfortably.

Top comments (0)