Skip to content
NEWMeet Alaaddin, your AI genie with a voice. trig8n launches 1 January 2027. See what is new

Library / AI Agents & Assistants

AI Agents & Assistants

Orchestrate multi-store order allocation with OpenAI, Postgres, and Slack

When an API call/webhook arrives, it runs an AI agent with OpenAI / ChatGPT using Postgres, Slack.

What it does

## Multi-Store Inventory Orchestrator An AI agent fulfills one order across multiple stores/warehouses: it checks live stock, builds an allocation plan, and reserves stock idempotently — retrying with backoff and escalating to a human instead of guessing when a reservation can't be resolved cleanly. ### How it works 1. A webhook receives the new order and normalizes it, deriving an idempotency key and session ID. 2. Postgres dedupes retried/duplicate webhooks before they ever reach the agent. 3. An AI Agent (GPT‑4.1) with four tools — check stock, reserve, release, and check rate limits — decides which stores to use, builds the allocation plan, and reserves stock. 4. The agent's structured JSON decision is logged to Postgres for audit and replay. 5. Fully-reserved orders auto-confirm; partial or failed allocations go to Slack for human ops review, then get confirmed or cancelled based on that decision. ### Setup steps 1. Add HTTP credentials for each store's inventory API (or unified middleware) on the four tool nodes. 2. Add an OpenAI credential for the agent. 3. Add a Postgres credential and create the inventory_orders and inventory_reservations tables. 4. Add a Slack credential on the ops-review notification node. 5. Point the manual-resolution Wait node's resume webhook at your ops dashboard. ### Customization tips Send a test order split across 2+ stores, with one intentionally out of stock, to exercise the escalation path end-to-end.

The steps

  1. Webhook - New Order
  2. Set - Config
  3. Postgres - Check Idempotency
  4. IF - Already Processed
  5. NoOp - Duplicate Ignored
  6. Tool - Check Store Stock
  7. Tool - Reserve Stock
  8. Tool - Release Reservation
  9. Tool - Get Store Rate Limit Status
  10. OpenAI Chat Model
  11. Window Buffer Memory
  12. AI Agent - Inventory Orchestrator
  13. Set - Parse Agent Output
  14. Postgres - Log Order Decision

22 steps in total.

Similar automations