Rag and NLP optimzied AI Chatbot
Here is my n8n automation program for Alto, our AI assistant, with it you will also find the n8n embedding process.

To accelerate our process, we needed an AI chatbot that could respond to most of our clients' questions about the project process.
We were already using a RAG-optimized chatbot on our landing page with the chatbot service CHATBASE, which is very easy to set up, but also expensive, and it could not respond to clients directly in our messaging system [ ref My web app project ].
So I decided to create myself a chatbot that could answer in discussions directly in the app and with Tiro's knowledge -> entirely in n8n [ ref My cloud computing project ].
I will present, step by step, each principal part of my process.
Here you can see the full program, which is pretty straightforward and short thanks to a lot a simplification work.

The first part is about data collection. I have a POST webhook that recovers every message sent on the platform. With the data present in the message table, I make a simple SQL query to recover information about the sender, receiver, and project. Then I check if the sender is an admin or the AI assistant itself ; if so, the workflow stops.

Then, thanks to the Supabase Vector Store Node: Get Many, it recovers 8 discussion parts that our human team had with clients, depending on their Cosinus Similarities.

—————
Here is a quick explanation of the process to add discussions to our vector store.
This workflow simply gets me a link in which I can upload documents, then these documents get split up every 200 tokens and get embedded with the OpenAI API and then simply load into our vector store.


—————
Then I merge all data from different data flows, create a prompt thanks to JavaScript, and ask an OpenAI Generation model to decide if the last messages need a response from the assistant.
It was pretty hard to get consistent response types, and I could not have a satisfying result through NPL classification.
Here is the prompt that works pretty well :
You are a binary classifier. Respond only with true or false.
⚠️ Important rule:
You have access to the messages exchanged between a student and an entrepreneur who are collaborating.
Respond true if you believe that a response from Tiro’s chatbot assistant is useful and necessary — for example, in cases of an explicit question, clear misunderstanding, request for help, or reported issue.
If no intervention is needed, respond false.
If the message content is missing or unavailable, respond false.
📄 Available documents to assist you (from RAG) (score: ${score})
${context}
💬 Last 3 messages of the conversation:
${messages}

Then, depending on the "classifier's" response, I create a new prompt with more information about Tiro and ask a new OpenAI Gen AI to generate an adapted message, and finally insert it into the database, which automatically updates the discussion with a new message from Alto : Tiro's assistant.

Here is an example of a classical utilization:

Translation :
User:
Hello, how does the payment system work?
Alto – Tiro Assistant:
Hello, the payment system on Tiro works by requesting full payment before connecting the entrepreneur with the students.
This ensures a smooth and secure process while keeping prices affordable.
If you have any other questions about payments or the platform, feel free to ask.
Thank you for reading me.