Automate Supply Chain Analytics Workflows with AI Agents using n8n


Why build things the hard way when you can design them the smart way?

As a Supply Chain Data Scientist, I’ve explored various frameworks like LangChain and LangGraph to build AI agents using Python.

Leveraging LLMs with LangChain for Supply Chain Analytics — A Control Tower Powered by GPT — (Image by Samir Saci)

The illustration above is from an article I wrote at the end of 2023, titled “Leveraging LLMs with LangChain for Supply Chain Analytics — A Control Tower Powered by GPT.”

At the time, I was exploring how to use LangChain to build an agent acting as a Supply Chain Control Tower.

A year later, I discovered the power of the low-code platform n8n to build the same kind of solution in just a few clicks.

AI-Powered Email Parser used for the processing of Warehouse Orders received by Email — (Image by Samir Saci)

In this article, we’ll explore how to easily build AI agents to automate supply chain analytics workflows using n8n.

AI Agent for Supply Chain Control Tower — (Image by Samir Saci)

We’ll also see how to deploy the same AI-powered Control Tower agent I originally built with LangChain 18 months ago — now using only low-code.

AI Agent for Supply Chain Control Towers using LangChain

My first project of AI Automation project using n8n was for a customer who wanted a Supply Chain Control Tower equipped with a chat interface.

A Supply Chain Control Tower is a set of dashboards and reports connected to Warehouse and Transport Management Systems that use data to monitor critical events across the supply chain.

Example of a control

In an earlier article published on Towards Data Science, I experimented with LangChain to connect a control tower to an AI agent.

High-Level Overview of the Solution presented in the article — (Image by Samir Saci)

The idea was to build a plan-and-execute agent that would

  • Process the user’s request written in plain English
  • Generate the appropriate SQL query
  • Query the database and store the results
  • Formulate a clear response in plain English

After several iterations, I found the right chain structure and prompts to deliver accurate results.

Example of iterations that you can find in the article — (Image by Samir Saci)

The solution worked well because I had already gained experience using LangChain and other frameworks to build AI agents.

How are we supposed to maintain this complex setup?

However, to offer this as a service, I needed tools that would make the solution easier to deploy, maintain, and improve — even with limited Python knowledge.

That’s when I discovered n8n.

Let’s dive into that in the next section.

AI Agent for Supply Chain Control Towers — Built with n8n

What is n8n?

n8n is an open-source workflow automation tool that lets you easily connect apps (email, CRMs, messaging systems), APIs, and AI model frameworks like LangChain.

You build workflows by connecting pre-built nodes.

AI-Powered Email Parser using 4 nodes — (Image by Samir Saci)

For instance, the workflow above processes emails

  • The first node collects emails from a Gmail account.
  • The email content and metadata are sent to the AI Agent node, which extracts the relevant information.
  • The third node processes the output using JavaScript.
  • The final node loads the results into a Google Sheet.

No code was needed to build this workflow — except for the third node, which uses just two lines of JavaScript.

Since I work with a team of Supply Chain consultants who have limited Python skills, this was a game-changer for me as I looked to develop my service offering.

They can easily use, adapt, and maintain this workflow after a short training session on n8n.

AI Supply Chain Control Tower n8n workflow

The AI Supply Chain Control Tower workflow is a bit more complex — but still far simpler than its Python version.

It includes two sub-workflows.

Main sub-workflow including the AI agent — (Image by Samir Saci)

The main sub-workflow includes both a chat interface and the AI agent.

For the AI Agent node, you need to

  • Connect an LLM (chat model) using a node where you enter your API credentials
  • Add a memory node to manage the conversation
  • Add a tool node for SQL querying, linked to the second sub-workflow

The AI agent generates an SQL query and sends it to the “Call Query Tool” node, which executes the query.

Second sub-workflow connected via the “Call Query Tool” — (Image by Samir Saci)

The sub-workflow includes a code node that cleans the query (removing extra spaces and blocking risky commands like DELETE).

The output is sent to a BigQuery node, which runs the query and returns the results.

The process is very smooth and requires limited configuration:

  • System Prompt (in the AI Agent node)
  • User Prompt (in the AI Agent Node)
System Prompt Window of the AI Agent Node — (Image by Samir Saci)

This setup requires no Python skills and can be handled directly by my consultants.

Chat Window showing an interraction with the AI Agent — (Image by Samir Saci)

The results are comparable to those of the Python version.

For step-by-step setup instructions, check out my YouTube tutorial 👇

Conclusion

This example shows how easy it is to replicate an AI agent built with Python — using n8n and minimal code.

Does that mean Python is no longer needed for Supply Chain Analytics? Definitely not!

Like many low-code platforms, the features are limited to what is available within the framework.

That’s why I use it as a complement to my analytics products.

Connect an AI Agent with one of my analytics products’ backend using an HTTP node — (Image by Samir Saci)

To do that, you can use the HTTP Request node to connect your workflow to your analytics backend.

What else? Easy connectivity to many services.

Another reason I chose n8n to enrich my analytics products is how easy it is to add additional connections.

For example, if you want to add a Slack interface or log conversations to a Google Sheet, just add a new node to your workflow.

If you’re starting your n8n journey and need inspiration, feel free to explore my templates.

About Me

Let’s connect on Linkedin and Twitter; I am a Supply Chain Engineer using data analytics to improve Logistics operations and reduce costs.

For consulting or advice on analytics and sustainable Supply Chain transformation, feel free to contact me via Logigreen Consulting.

Samir Saci | Data Science & Productivity
A technical blog focusing on Data Science, Personal Productivity, Automation, Operations Research and Sustainable…samirsaci.com



Recent Articles

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here