Building AI chatbots with RAG: a step-by-step guide
Jon Gitlin
Senior Content Marketing Manager
at Merge
As large language models (LLMs) continue to improve, organizations see increasing value in incorporating AI chatbots into their products.
AI chatbots can now address customer issues effectively; answer employeesâ questions with high precision; help employees build robust analytics dashboards quicklyâand much more.
The process of building these chatbots, however, isnât always straightforward.Â
To help guide you through the process, weâll break down several steps you should take. But first, letâs align on what an AI chatbot is and why itâs important.
What is an AI chatbot?
Itâs a chat interface that leverages RAG to answer usersâ questions or take actions on their behalf. It can be used across your product and in immeasurable ways, as long as it can access all of the relevant data.
While the reasons depend on the business and their unique requirements, here are some that apply to many companies:
Addresses usersâ questions quickly: AI chatbots can address prompts in a matter of seconds (if not faster). This is not only a great customer experience but also allows users to tackle tasks and/or get issues resolved quickly (which helps explain why chatbots are often used to improve the customer experience)
Increases conversion rates on leads: By using AI chatbots to surface leads to the right reps, reps can reach out sooner, whichâaccording to a prominent studyâshould help them convert leads at a higher rate
Improves employee engagement: AI chatbots can tackle many repetitive tasks that your employees would otherwise have to perform. This allows your employees to save countless time and focus on the work theyâre more likely to enjoy
Cost savings: Since AI chatbots can complete a wide gamut of tasks effectively, they can lower headcount both now and in the future, saving companies countless money
Competitive differentiation: Many companies in your space may not have adopted AI chatbots in their product, or at least not in the ways your team is scoping. If you can be the first mover in incorporating AI chatbots for a certain use case, you can earn and maintain a meaningful competitive advantageÂ
The step-by-step process of building an AI chatbot
Hereâs a breakdown of each step youâll need to take.
1. Define your objective
Your objective will be key for executing on the rest of the steps, so itâs critical to establish it at the beginning.
It requires several inputs: the core purpose of your chatbot; the KPI(s) you want it to influence; and the audience you want to use it on (at least initially). Youâll also want to incorporate a goal-setting frameworkâe.g., SMARTâso that the goal is actionable.
For example, if you offer an AI chatbot for employees, your goal can be the following: Improve your customersâ average Net Promoter ScoreÂŪ by at least 5 points, on average, within 3 months.
Youâll need to decide between an open-source chatbot framework, such as Rasa or Botpress, and a cloud-based platform, like Dialogflow, Ema, and AmazonQ.
The best choice depends on a few factors:
Customizability: If you have highly custom requirements, you may need to use an open-source chatbot framework, as it offers more flexibility in how it can be integrated with applications, the workflows it can support, and more
Scalability: If you plan to roll out the chatbot to a large audience (or you eventually plan to do so), it may be worth using a cloud-based platform as they handle the infrastructure on your behalf
Time to market: If your team needs to push the chatbot live as soon as possible, the cloud-based platform will likely be a better choice, as its implementation is likely simpler and easier
Resources: The process of building and maintaining chatbots can be fairly technical, and your team either may not have the resources on hand to manage this project or canât afford to allocate them to it. This would force your team to use a cloud-based platformâ
Connectivity: If the chatbot needs to be integrated with several applications, it may be worth using a cloud-based platform. These platforms typically offer pre-built connections and may offer additional support for building new connections (e.g., technical teams on their side can add integrations on your behalf).
In short, thereâs no one-size-fits-all answer, but youâll likely want to use a cloud-based platform.Â
3. Design the conversation flow
Once youâve picked the solution, youâll need to craft the conversation path based on all of the user inputs that can come up. Youâll also need to consider potential edge cases in user inputs and how the chatbot should respond to them.
Fortunately, this step is getting increasingly easier with the help of natural language processing (NLP).Â
Many tools let you use plain text to describe the workflow you want an AI chatbot to support and the tool can use an LLM to then generate that workflow on your behalf. You can even iterate on it in plain text, helping you land on the most optimal workflow.
Ema, a universal AI employee, lets you build AI agents and chatbots through simple descriptions
4. Train your AI chatbot
Your AI chatbot ultimately needs to access your customersâ latest data to provide personalized and actionable outputs.
For example, it canât help a customer support rep tackle a specific client issue if it canât access and interact with the customer support repâs ticketing system.
To that end, youâll need to build API-based integrations (as opposed to file-based integrations, which are slower and error prone) with all of the systems that support your chatbotâs use cases.
Since Emaâs AI chatbots and agents can help employees across departments, their platform offers integrations with several software categoriesâfrom file storage to ticketing systems to CRMs
Youâll also need to fine tune the chatbot based on user inputs; so while the chatbot may not perform well at the beginning, it should consistently improve.
The integrations that support your chatbot should include access control levels (ACLs), which ensure that users only access the data that meets their level of permissions in that integrated application.Â
For example, if a user is asking your chatbot for sensitive business information, the chatbot can determine that that user doesnât have access to the file that contains the informationâleading your chatbot to not share it.
6. Test and monitor the chatbot
Before pushing the chatbot to production, your team should test it with a wide range of inputs, including the edge cases. You should also share it with colleagues who are your target user profiles who havenât spent as much time working on the chatbot. They can approach it with a fresh pair of eyes and see issues you canât.Â
Finally, your team should also monitor the chatbot soon after it goes live as small issues can have a long-term impact on how it gets perceived.Â
Best practices for creating an AI chatbot
As you build your AI chatbot, itâs worth keeping the following in mind:
Create a chatbot personality that reflects your brand values. Your chatbot is often the first line of communication for prospects, and your customers and employees will likely interact with it often. As a result, itâs critical that the chatbot interacts with users in a way that reflects your brandâs core valuesâwhether thatâs humility, integrity, kindness, and so on
Provide links to the sources used in its outputs. Whether fair or not, LLMs have gained a reputation for hallucinating, or generating inaccurate outputs.
To give users confidence that your AI chatbot provides accurate information, you can include the sources used in a given output and make it clickableâallowing users to verify the information and learn more.
Your AI chatbot can include sources in every response it generates, allowing users to not only verify information but also access the documents they need, quickly
Offer suggested prompts by default. Many users may not know what your AI chatbot is capable of. They also might not think of the most valuable ways to use it. To help guide them in the right direction, you can offer suggestions and even provide brief descriptors of what your chatbot can do (this is especially helpful when itâs the userâs first time using your chatbot)
Use webhooks when possible. Webhooks allow your chatbot to access and use real-time data when generating outputs. This can prove critical for several use cases, from sharing warm leads to sales reps to sharing security incidents
Revisit your AI chatbotâs performance regularly. Your chatbotâs level of adoption may drop after a few months or even a few years based on the quality and value of its outputs. Noticing when this happens and being able to diagnose and address the root cause on time is critical to providing a best-in-class chatbot over time
Expand your AI chatbot offerings once your first one succeeds. After youâve figured out the right process for building AI chatbots, you can explore additional chatbot applications for your product and apply the same process to implement them
Report on your chatbotâs performance to the C-suite. Your C-suite likely feels pressure from the board of directors to invest in all kinds of AI product features and capabilities. Being able to show your C-suite that your AI chatbot not only exists but is also getting adoption and providing value can help them handle these board conversations and allow you to secure buy-in for additional investmentsâ
Experiment with different LLMs to optimize performance. Depending on the chatbot framework, you may be able to pick and choose the LLM(s) that powers your AI chatbot. When thatâs the case, itâs worth trying out a few for anticipated use cases and then moving forward with the one that produces the most reliable, personalized, and high quality outputs.
Leverage a unified API solution.A unified API solution offers a single, aggregated API to help you add hundreds of integrations. Since your customersâ tech stacks likely vary, and you may need to support different categories of integrations to cover all of your chatbotâs use cases, this can help you take your chatbot to market faster
Merge lets you add 220+ product integrations across 6 software categories
Feed normalized data to the LLM that powers your chatbot. Normalized data, or data thatâs transformed to fit a predefined data model, can be embedded more accurately, as it doesnât include miscellaneous information. This allows it to be identified for relevant prompts consistently, leading it to be fed to the AI chatbotâs LLM and used in outputsÂ
An AI chatbot can use normalized data to answer promptsâlike âGive me the marketing teamâs first names and email addressesââsuccessfully
Merge, the leading unified API solution, lets you add hundreds of HRIS, ATS, file storage, ERP, ticketing, and CRM integrations through a single build.Â
Merge also:
Normalizes all of the integrated data across its integrations according to its Common Models
Offers Integration Observability features to help your customer-facing teams manage any integration issues
Supports webhooks to help your chatbot use real-time data
In case you have any more questions, weâve addressed several more below.
What is an example of a RAG-powered AI chatbot?
One example comes from Assembly, a comprehensive HR software platform.
They offer DoraAI, an AI chatbot that can answer their customersâ employeesâ questions in plain text (using natural language processing) based on the files it has access to. DoraAI can also display the source(s) it used in its answer in case the user wants to learn more.
How much does it cost to build an AI chatbot?
The cost varies depending on the chatbot platform you use, the types of data your chatbot needs, the extent to which customers adopt your chatbot, and more.Â
Given all these factors, the cost can range anywhere from a few thousand dollars to hundreds of thousands of dollars every year.
When is it worth investing in an AI chatbot?
Thereâs no âbest time.â You might move to build one quickly when customers or prospects request it and/or when your competitors start rolling them out, but it likely comes down to how the chatbot would fit into your product strategy and whether itâs worth prioritizing over other net-new features or product improvements.
Jon Gitlin
Senior Content Marketing Manager
@Merge
Jon Gitlin is the Managing Editor of Merge's blog. He has several years of experience in the integration and automation space; before Merge, he worked at Workato, an integration platform as a service (iPaaS) solution, where he also managed the company's blog. In his free time he loves to watch soccer matches, go on long runs in parks, and explore local restaurants.
Read more
Bring dots to work with Merge for Workforce
Product
Bring Grok Bot to work with Merge for Workforce
Migrate integrations to Merge Unified without asking your customers to re-auth