Automate Supply Chain Analytics Workflows with AI Agents using n8n

-

Why construct things the hard way when you may design them the smart way?

As a Supply Chain Data Scientist, I’ve explored various frameworks like LangChain and LangGraph to construct 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 top of 2023, titled “Leveraging LLMs with LangChain for Supply Chain Analytics — A Control Tower Powered by GPT.”

On the time, I used to be exploring the best way to use LangChain to construct an agent acting as a Supply Chain Control Tower.

A 12 months later, I discovered the facility of the low-code platform n8n to construct the identical sort of solution in only just a few clicks.

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

In this text, we’ll explore the best way to easily construct 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 the best way to deploy the identical 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 watch critical events across the provision chain.

Example of a control

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

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

The thought was to construct a plan-and-execute agent that might

  • Process the user’s request written in plain English
  • Generate the suitable SQL query
  • Query the database and store the outcomes
  • Formulate a transparent response in plain English

After several iterations, I discovered the precise chain structure and prompts to deliver accurate results.

Example of iterations that you would be able to find within the article — (Image by Samir Saci)

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

Nevertheless, to supply this as a service, I needed tools that might make the answer easier to deploy, maintain, and improve — even with limited Python knowledge.

That’s once I discovered n8n.

Let’s dive into that in the following section.

AI Agent for Supply Chain Control Towers — Built with n8n

What’s n8n?

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

You construct workflows by connecting pre-built nodes.

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

For example, the workflow above processes emails

  • The primary node collects emails from a Gmail account.
  • The e-mail content and metadata are sent to the AI Agent node, which extracts the relevant information.
  • The third node processes the output using JavaScript.
  • The ultimate node loads the outcomes right into a Google Sheet.

No code was needed to construct this workflow — apart from the third node, which uses just two lines of JavaScript.

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

They’ll easily use, adapt, and maintain this workflow after a brief training session on n8n.

AI Supply Chain Control Tower n8n workflow

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

It includes two sub-workflows.

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

The principal sub-workflow includes each a chat interface and the AI agent.

For the AI Agent node, you must

  • Connect an LLM (chat model) using a node where you enter your API credentials
  • Add a memory node to administer 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 features a code node that cleans the query (removing extra spaces and blocking dangerous commands like DELETE).

The output is shipped to a BigQuery node, which runs the query and returns the outcomes.

The method could be very smooth and requires limited configuration:

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

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

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

The outcomes are comparable to those of the Python version.

For step-by-step setup instructions, try my YouTube tutorial 👇

Conclusion

This instance shows how easy it’s to copy an AI agent built with Python — using n8n and minimal code.

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

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

That’s why I take advantage of it as a complement to my analytics products.

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

To do this, you should utilize the HTTP Request node to attach your workflow to your analytics backend.

What else? Easy connectivity to many services.

One more reason I selected n8n to complement my analytics products is how easy it’s so as to add additional connections.

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

Should you’re starting your n8n journey and wish inspiration, be at liberty to explore my templates.

About Me

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

For consulting or advice on analytics and sustainable Supply Chain transformation, be at liberty to contact me via Logigreen Consulting.

Samir Saci | Data Science & Productivity
samirsaci.com

ASK ANA

What are your thoughts on this topic?
Let us know in the comments below.

0 0 votes
Article Rating
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Share this article

Recent posts

0
Would love your thoughts, please comment.x
()
x