Reroute delayed shipments with OpenAI, Google Sheets, Telegram, Slack, and Gmail

Go to Workflow
0 views
Built by Rahul Joshi Rahul Joshi
Created on September 08, 2026

Description

Quick overview
This workflow runs every 30 minutes to detect delayed shipments from Google Sheets, sends a delay summary to Telegram, uses OpenAI to recommend alternate routes from a routing API, requests approval in Slack when needed, updates the carrier TMS via HTTP, notifies via Gmail, and logs outcomes Sheets and Slack

How it works
Runs every 30 minutes on a schedule trigger.
Reads active shipments from Google Sheets and identifies delayed ones by comparing Promised Delivery vs Current ETA (or a “delayed” status), then calculates delay hours.
Builds a delay summary and sends a Telegram alert when at least one delayed shipment is found.
For each delayed shipment, calls a routing HTTP API to fetch alternate routes and sends the shipment + route options to OpenAI (gpt-4o-mini) to get a structured reroute recommendation.
If the AI flags the decision as requiring approval, sends an interactive Slack approval request and waits for an approve/reject response.
For approved (or auto-approved) reroutes, calls the carrier TMS HTTP API to update the route, updates the shipment record in Google Sheets, emails the customer via Gmail, and posts a confirmation to Slack.
For rejected reroutes, marks the shipment as escalated for manual review in Google Sheets and notifies the ops Slack channel.

Setup
Add credentials for Google Sheets OAuth2, OpenAI, Telegram Bot API, Slack OAuth2, and Gmail OAuth2.
Update the Google Sheets document ID and ensure the “Active Shipments” sheet exists with columns like Shipment ID, Customer, Customer Email, Carrier, Origin, Destination, Promised Delivery, Current ETA, Status, and Priority.
Replace the routing API and carrier TMS API base URLs in the two HTTP Request nodes and configure the required HTTP header auth credentials/headers.
Set your Telegram chat ID and Slack channel ID(s) used for approvals and ops notifications.
Update the Gmail recipient mapping (the template uses a placeholder email) to send to each shipment’s Customer Email field.

Nodes Used (7)

Code
n8n-nodes-base.code
Gmail
n8n-nodes-base.gmail
Google Sheets
n8n-nodes-base.googleSheets
HTTP Request
n8n-nodes-base.httpRequest
OpenAI
@n8n/n8n-nodes-langchain.openAi
Slack
n8n-nodes-base.slack
Telegram
n8n-nodes-base.telegram