Building the AIFN chatbot in an afternoon
The rise of large language models (LLMs) has revolutionized the way we interact with information. One particularly useful application of LLMs is a chatbot, whether for customers (external) or internet corporate use. Unlike traditional chatbots prior to 2022 which are limited to pre-defined responses, LLM-based chatbots can access and process vast external knowledge bases, providing more comprehensive and contextually relevant answers, and with today’s tooling, one can easily build a chatbot in a few hours with no coding required. A little WordPress knowledge and creativity are all that is needed.
This guide will explain how I build the AI-First Nation: A blueprint for policy makers and organisation leaders (AIFN) book chatbot (AIFNbot) in an afternoon. AIFNbot is a standard LLM-based chatbot employing Retrieval Augmented Generation (RAG) techniques to anchor the chatbot’s ground truth with documents supplied by me. This chatbot makes use of OpenAI’s GPT-4o-mini for costs reasons. We can use GPT-4o, Google Gemini and even a self-hosted Ollama instanceas the LLM, the cloud-based Pinecone vector database to store the documents’ embeddings, WordPress and the very easy to use but powerful AI Engine Pro from MeowApps WordPress plugin.
Building a WordPress LLM-RAG Chatbot
I will assume you are familiar with setting up and running a basic WordPress site and know how to sign up for a cloud service and get required API keys. The high-level steps to build the chatbot are:
- Install WordPress and theme it with your favourite theme if you do not yet have WordPress.
- Download and install AI Engine from MeowApps into your WordPress instance. You will need the Pro version (US$59.00/year) to have Embeddings feature.
- Sign up for an OpenAI API account for an API key (note that this differs from ChatGPT sign up although both are provided by OpenAI).
- Sign up for a Pinecone account (the free Starter tier suffice for this tutorial and small sites) for the Pinecone API key.
- Configure your chatbots with the AI Engine GUI
- Select your chatbot engine (OpenAI GPT4o-mini in this instance)
- Enter your prompt and other parameters
- Configure your WordPress articles to be indexed by Pinecone
- Prepare your external documents that is not part of your WordPress site for example (product documentation, FAQs, articles) in TEXT format and upload them to be indexed by Pinecone
- Copy and paste the AI Engine shortcode to your WordPress page (or enable it to run for your whole site)
- Test
- Go live and monitor!
- Adjust your prompt as required.
- Test
Powering your Chatbot with AI Engine
AI Engine Pro from MeowApps (I declare I have no financial benefit from mentioning them here, I am just a satisfied customer) does all the magic required. It is a no-code, easy way to deploy a powerful LLM-RAG (or no RAG) chatbot very quickly within a WordPress site.

Dashboard
After installing the AI Engine, navigate to its dashboard and ensure that the Chatbot is enabled in the Client Modules. In Server Modules, enable both Statistics and Embeddings. In Admin modules enable those which you want, they are not required for the chatbot feature but some are useful as part of your WordPress site.

Settings
Next tab you want to go to would be the Settings tab. Here, enter your OpenAI API keys, and also your Pinecone API key, and also the Pinecone Server URL. If required, you may wish to enable GDPR consent. I recommend also that you enable Chatbot->Discussions and Statistics-> Queries Data at least during the initial launch/pilot/trial period, so that you can monitor the activities and usage, so that you can adjust your system prompts, change various parameters, etc. Of course, inform your users that their queries and discussions with your chatbot are being recorded.

Go to AI Environment, select OpenAI which offers 3 different embeddings. You may have to experiment with them to see which works best for your data. For the AIFN chatbot, I used Embedding 3-Small with 1536 (default) as the dimensions.

Embeddings
Large Language Models (LLMs) are prone to producing hallucinations, so many chatbots that provide corporate information employ a technique called Retrieval Augmented Generation (RAG). RAG effectively anchors your chatbot to a knowledge base, which may include documents, FAQs, sales data, articles, and more.
To enable AI Engine to search your knowledge base, your content will need to be transformed into a format it understands: embeddings. Embeddings are mathematical representations of text, capturing semantic meaning and relationships between words and sentences. AI Engine can generate these embeddings for both user queries and your knowledge base documents.
The Pinecone Vector Database
Pinecone is a purpose-built vector database on the cloud, designed specifically for storing, indexing, and querying high-dimensional vectors also knwon as embeddings, making it an ideal companion for AI Engine in the RAG chatbot applications.
Once the knowledge base is converted into embeddings by AI Engine, these embeddings are uploaded and stored within Pinecone. Pinecone’s indexing capabilities ensure that even with millions of embeddings, similarity searches remain lightning-fast. This is crucial for providing a smooth and responsive user experience, as delays in retrieving information can quickly lead to frustration.
With the embeddings for both the content and user queries, the search process is all about finding the closest matches. This is where the idea of “semantic similarity” becomes important. The AI Engine measures the distance between the query and each document embedding. Smaller distances mean the documents are more similar to the query. AI Engine finds and shows the most relevant documents by comparing their similarity scores.
Below, we show the workflow of the RAG technique. The user’s prompt is used to search the database (Pinecone is a cloud service) for relevant documents. The documents, together with the system prompt and the original user’s prompt are then fed to the LLM (GPT4o-mini is a cloud service), which will generate the output grounded by the documents provided.

Go to the Embeddings tab. Here you can upload TEXT documents and also select your posts to sync to the Pinecone vector database you setup earlier.


Chatbots
In the Chatbot tab, choose a descriptive name for your chatbot, leave the ID as is. Enter your system prompt in the Instructions field. Your prompt design will determine how your chatbot is going to perform and how good it is. For the AIFNbot, my system prompt includes the following sections:
- Tell the LLM what persona to take
- Ask it to read 3 of my old articles (written before the days of LLM) and to use my style and tone when replying
- Instructions on how to answer questions and to restrict to information about the AIFN book and AI Singapore programmes only
- Guardrails (jailbreak prevention) statements

Still in the Chatbot tab, click on AI Model, choose the LLM you want to use. For the AIFNbot(v6), I choose to use GPT4o-mini as the output is decent and cost is low. (AIFN is a self-funded site, including all the LLM APIs calls).

Click on Context, and in Embeddings->Environment, select the Pinecone environment you setup earlier.

Click on Appearance and configure your Start Sentence, your Avatars, and different Themes to change the look and feel. Importantly, your Compliance Text to let your user know you are collecting the chat sessions. For the AIFNbot, I use:
This is a AI-powered chatbot and no human is here. Please do not enter your personal information. Your chat sessions will be recorded and reviewed to improve future editions of the AIFN book and also help craft new AI Singapore's programmes. Please note that the answers provided here may not be 100% correct all the time. Thank You.

You are basically done! Test your chatbot. Make sure it responds as you expected. If you are happy with the outputs, copy the shortcode into your WordPress page, or enable Site-Wide Chatbot, and the chatbot will appear on all pages at the lower right (default) corner of your website.
Monitor how people are using your chatbot, and you may find people jail breaking your bot, and then you will have to tighten your guardrails. I have observed that GPOT4o-mini is easier to jail break than GPT4o. So experiment.
Other features of AI Engine
Besides allowing you to create chatbots, AI Engine also provides helpful tools like Content and Image creations right within your WordPress dashboard. In fact, this article’s first draft was generated with AI Engine Pro Content feature.

Conclusion
If all your data are your post and webpages on your WordPress website, you can be up and running in as little as 1-2 hours. If you have external documents, you need to convert them to text (WORD -> Export to TXT), same for PDFs etc. I am sure in the near future, the AI Engine developer will provide a feature to just upload docx and pdfs directly. The creation and curation of your knowledge base will take the longest time, followed by customizing your system prompt to ensure the chatbot behaves as you require. A tip: you can use ChatGPT or Google Gemini to generate your system prompt – at least the first draft – and then you refine it from there.
Building a sophisticated RAG chatbot that not only understands natural language but also provides accurate, contextually relevant answers that taps into your knowledge base, is very easy today. In fact, I spent more time writing this article than building the RAG version of the AIFN chatbot this afternoon.