Connect Adobe Commerce to AI Agents: Sync Sales Rules and Taxes
Give your AI agent Adobe Commerce tools.
A technical guide to connecting Adobe Commerce (Magento) to AI Agents. Overcome Magento's searchCriteria and nested payload quirks with Truto's unified tool layer.
In this guide
- 01Initialize the Truto Tool Manager
- 02Fetch Adobe Commerce Tools
- 03Bind Tools to the LLM
- 04Implement Rate Limit Handling
- 05Execute the Agent Workflow
The guide
Learn how to connect Adobe Commerce to AI Agents using Truto. Fetch AI-ready tools, bind them to LLMs, and automate sales rules, taxes, and orders.
You want to connect Adobe Commerce to an AI agent so your system can autonomously adjust tax rates, sync sales rules, audit active coupons, and manage order lifecycles. Here is exactly how to do it using Truto's /tools endpoint and SDK, bypassing the need to build and maintain a custom Magento connector from scratch.
Giving a Large Language Model (LLM) read and write access to your Adobe Commerce (formerly Magento) instance is an engineering headache. You either spend sprints building, hosting, and maintaining a custom integration layer, or you use managed infrastructure that handles the boilerplate for you. If your team uses ChatGPT, check out our guide on connecting Adobe Commerce to ChatGPT, or if you are building on Anthropic's models, read our guide on connecting Adobe Commerce to Claude. For developers building custom autonomous workflows, you need a programmatic way to fetch these tools and bind them to your agent framework.
This guide breaks down exactly how to fetch AI-ready tools for Adobe Commerce, bind them natively to an LLM using frameworks like LangChain, LangGraph, CrewAI, or the Vercel AI SDK, and execute complex e-commerce operations safely. For a deeper look at the architecture behind this approach, refer to our research on architecting AI agents and the SaaS integration bottleneck.
Why a Unified Tool Layer Matters for Agent Safety
Before writing a line of integration code, decide what layer your agent talks to. This choice determines how safe your production system will be.
Direct API tools - exposing one tool per raw Adobe Commerce endpoint - look convenient, but they push provider-specific quirks directly into the LLM's context window. The model has to remember that Adobe Commerce requires highly nested payload envelopes, complex searchCriteria query strings for filtering, and specific URL-encoding rules for SKUs. Every one of those quirks is a hallucination waiting to happen.
A unified tool layer collapses these complexities behind a clean, normalized schema. Your agent sees list_all_adobe_commerce_sales_rules and create_a_adobe_commerce_tax_rule with flat input parameters. That gives you distinct safety wins:
- Smaller attack surface for hallucination. The LLM only ever chooses from a stable list of function names with predictable inputs. It never invents Magento
filter_groupsoperators. - Deterministic input validation. Every tool has a strict JSON schema. Invalid arguments are rejected before they hit the commerce engine, so a broken tool call fails fast instead of corrupting store data.
- Decoupled execution. The agent reasons about what to do, while the Proxy API handles how to authenticate, paginate, and shape the HTTP request.
The Engineering Reality of the Adobe Commerce API
Giving an LLM access to external data sounds simple in a prototype. You write a Node.js function that makes a fetch request and wrap it in an @tool decorator. In production against complex e-commerce systems like Adobe Commerce, this approach collapses quickly.
The Adobe Commerce API introduces several specific integration challenges that break standard REST assumptions. If you hardcode these interactions into your agent, you will spend your sprints writing defensive integration code instead of improving your model's reasoning.
The searchCriteria Query Trap
Standard REST APIs use intuitive query parameters like ?status=active&limit=50. Adobe Commerce uses a highly verbose searchCriteria syntax designed for complex AND/OR filtering. To filter orders by a specific customer, a raw request looks like this:
GET /V1/orders?searchCriteria [filter_groups][0][filters][0][field]=customer_email&searchCriteria [filter_groups][0][filters][0][value]=test@example.com&searchCriteria [filter_groups][0][filters][0][condition_type]=eq
If you expose this raw requirement to an LLM, it will frequently hallucinate the array indexing ([0][filters][1]) or completely forget the condition_type. Truto's Proxy API abstracts this away entirely. The agent simply calls the list tool with standard inputs: filter_field="customer_email", filter_value="test@example.com", and Truto translates it into the dense searchCriteria payload downstream.
Nested Payload Envelopes
LLMs are trained to generate flat, intuitive JSON objects. If an agent wants to update a tax class, it naturally attempts to send {"class_name": "Retail Tax", "class_type": "CUSTOMER"}.
Adobe Commerce rejects this. The API rigidly enforces payload envelopes based on the entity type. To update a tax class, the body must be wrapped exactly as {"taxClass": {"class_name": "Retail Tax", "class_type": "CUSTOMER"}}. If an agent tries to update a product, it must be {"product": {...}}. Truto's tool schemas strictly define these envelopes, forcing the LLM to output valid nested JSON before the request is ever dispatched.
Pagination and Cursors
Adobe Commerce paginates using searchCriteria [currentPage] and searchCriteria [pageSize]. Relying on an LLM to manage its own pagination cursors across multiple reasoning steps destroys token context and leads to infinite loops. Truto handles pagination at the proxy layer. When the agent calls a list tool, Truto automatically pages through the upstream API (up to a safe limit, typically 300 records) and returns a consolidated array of items.
Adobe Commerce Tools for AI Agents
Truto provides a comprehensive set of AI-ready tools by dynamically mapping Adobe Commerce endpoints to unified resources and methods. You fetch these tool schemas via the /tools endpoint and inject them into your agent framework.
Here are the highest-leverage hero tools for managing sales rules, taxes, and order workflows.
list_all_adobe_commerce_sales_rules
Retrieves active promotional rules, cart discounts, and coupons. This tool supports Truto's simplified filter_field and filter_value parameters, making it easy for an agent to audit active promotions without wrestling with Magento's query syntax.
"Fetch all active sales rules in the system to see if the 'Summer Sale 20% Off' rule is still running."
update_a_adobe_commerce_sales_rule_by_id
Modifies an existing sales rule. This is critical for agents tasked with rotating seasonal promotions or disabling expired discount codes. The id is the Magento ruleId, and the payload must be passed inside a rule envelope.
"The Summer Sale is over. Find rule ID 45 and update its status to inactive, then log the change."
create_a_adobe_commerce_tax_rule
Generates a new tax rule binding a customer tax class, product tax class, and tax rate together. The API handles POST and PUT operations against the same save method, so passing a rule.id in the payload will update an existing rule.
"Create a new tax rule named 'California Digital Goods' that links the CA 8.5% rate to the 'Downloadable' product tax class."
update_a_adobe_commerce_tax_class_by_id
Updates the metadata for a specific tax class (either Product or Customer). The agent must provide the classId as the identifier and wrap the body in a taxClass object.
"Update the tax class ID 12. Change its name to 'Wholesale Exempt' and ensure its class_type is set to CUSTOMER."
list_all_adobe_commerce_orders
Retrieves order records. Truto pages this automatically up to the max limit. This tool is frequently used by agents to compile abandoned cart reports or audit unfulfilled high-value orders.
"Pull a list of all orders placed yesterday where the grand total exceeds $500, and check their current status."
create_a_adobe_commerce_invoice_capture
Captures funds for an existing invoice using an online payment method. This is an irreversible financial action. If the invoice was generated for an offline method (like check or bank transfer), the Commerce API will explicitly return an error stating the capture action is not available.
"Capture the payment for invoice ID 8892. If the upstream system returns an error about offline methods, notify the billing team."
To see the complete tool inventory, including full JSON schemas for catalog management, MSI (Multi-Source Inventory), and fulfillment, visit the Adobe Commerce integration page.
Building Multi-Step Workflows
To build autonomous workflows, you fetch the tool definitions from Truto's /integrated-account/<id>/tools endpoint and bind them to your agent. Because Truto outputs standard JSON schemas, this works identically whether you are using LangChain, LangGraph, CrewAI, or the Vercel AI SDK.
Here is how you initialize the tools using the truto-langchainjs-toolset SDK:
import { ChatOpenAI } from "@langchain/openai";
import { AgentExecutor, createToolCallingAgent } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";
import { TrutoToolManager } from "truto-langchainjs-toolset";
async function runCommerceAgent() {
// 1. Initialize the Truto Tool Manager with your Integrated Account ID
const toolManager = new TrutoToolManager({
trutoToken: process.env.TRUTO_API_KEY,
integratedAccountId: "acc_adobe_commerce_123xyz",
});
// 2. Fetch the tools dynamically from the Truto API
const tools = await toolManager.getTools();
// 3. Bind the tools to your LLM
const llm = new ChatOpenAI({
model: "gpt-4o",
temperature: 0,
});
const llmWithTools = llm.bindTools(tools);
// 4. Create the prompt and agent loop
const prompt = ChatPromptTemplate.fromMessages([
["system", "You are a senior e-commerce manager. You handle taxes, sales rules, and orders."],
["placeholder", "{chat_history}"],
["human", "{input}"],
["placeholder", "{agent_scratchpad}"],
]);
const agent = createToolCallingAgent({ llm: llmWithTools, tools, prompt });
const executor = new AgentExecutor({ agent, tools });
// 5. Execute a workflow
const result = await executor.invoke({
input: "Check if we have a tax class named 'Digital Services'. If not, create it."
});
console.log(result.output);
}Handling API Rate Limits
When your agent chains multiple reads and writes together, you will eventually hit Adobe Commerce's API rate limits. It is critical to understand that Truto does not retry, throttle, or apply backoff on rate limit errors.
When the upstream Adobe Commerce API returns an HTTP 429 Too Many Requests, Truto passes that error directly back to the caller. However, Truto normalizes the upstream rate limit information into standardized HTTP headers per the IETF specification:
ratelimit-limit: The maximum number of requests permitted in the current window.ratelimit-remaining: The number of requests left in the current window.ratelimit-reset: The time at which the current rate limit window resets.
Your agent framework or execution loop is entirely responsible for reading these headers, sleeping the thread, and retrying the failed tool call.
sequenceDiagram
participant LLM as Agent Framework
participant Truto as Truto Proxy API
participant Adobe as Adobe Commerce API
LLM->>Truto: Execute tool: list_all_adobe_commerce_orders
Truto->>Adobe: GET /V1/orders?searchCriteria...
Adobe-->>Truto: HTTP 429 Too Many Requests
Truto-->>LLM: HTTP 429 (Normalized Headers:<br>ratelimit-reset: 1715000000)
Note over LLM: Agent intercepts 429<br>Extracts ratelimit-reset<br>Sleeps for required duration
LLM->>Truto: Retry tool: list_all_adobe_commerce_orders
Truto->>Adobe: GET /V1/orders?searchCriteria...
Adobe-->>Truto: HTTP 200 OK
Truto-->>LLM: Normalized JSON ArrayWorkflows in Action
Once the tool layer is bound and rate limit handling is in place, your agent can execute complex e-commerce workflows autonomously. Here are two real-world scenarios.
Scenario 1: Seasonal Sales Rule Audit
Marketing teams frequently create promotional rules and forget to disable them, leading to margin erosion when old coupon codes leak online. An AI agent can audit and enforce hygiene.
"Find all active sales rules in the system. Identify any rule containing the word 'Winter' or 'Holiday' from last year. Disable them and provide a summary of what was deactivated."
Agent Execution Steps:
- The agent calls
list_all_adobe_commerce_sales_rules. Truto handles the pagination to return a complete array of rules. - The LLM processes the JSON response in its context, filtering for rules that are
is_active: trueand match the semantic criteria ('Winter', 'Holiday'). - The agent loops through the identified target rules.
- For each target, the agent calls
update_a_adobe_commerce_sales_rule_by_id, settingis_active: falseinside therulepayload envelope. - The agent compiles the results of the update calls and outputs a plain-text summary to the user.
Scenario 2: Tax Rate Compliance Updates
When a specific jurisdiction changes its local tax rate, updating this manually in Magento requires navigating multiple screens to update rates and verify rules. An agent handles this programmatically.
"The California state tax rate is increasing from 7.25% to 7.50%. Find the existing CA state tax rate, update the percentage to 7.50, and verify which tax rules currently use this rate."
Agent Execution Steps:
- The agent calls
list_all_adobe_commerce_tax_ratesusing Truto's filter parameters (filter_field=region_name,filter_value=California) to locate the specific rate ID. - The agent calls
create_a_adobe_commerce_tax_rate(which handles both POST and PUT). It passes the retrieved rate ID in the payload alongside the updatedrate: 7.50. - To verify application, the agent calls
list_all_adobe_commerce_tax_rules. - The agent cross-references the returned rules to see which ones contain the updated tax rate ID, and replies to the user with a list of impacted tax rules.
Wrapping Up
Connecting an AI agent to Adobe Commerce requires more than just API credentials. You must protect the LLM from Magento's complex payload envelopes, abstract the notoriously verbose searchCriteria syntax, and handle robust pagination logic.
By leveraging Truto's dynamically generated tool schemas and Proxy API, you strip away the integration boilerplate. Your agents get deterministic, safe functions they can reliably chain together to execute revenue-impacting workflows - from disabling stale coupons to capturing invoice payments - without hallucinating invalid REST parameters.
FAQ
- How does Truto handle Adobe Commerce API rate limits?
- Truto does not retry, throttle, or absorb rate limit errors. When Adobe Commerce returns an HTTP 429, Truto passes the error to your application and normalizes the rate limit information into standard headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset). Your agent framework must handle the retry backoff.
- Do I have to write custom searchCriteria strings for the agent?
- No. Truto abstracts Magento's complex searchCriteria syntax. Your agent uses simple, flat parameters like filter_field and filter_value, which Truto automatically translates into the correct nested query downstream.
- Can I use these tools with LangGraph or CrewAI?
- Yes. Truto exposes tools as standard JSON schemas via the /tools API endpoint. This format is framework-agnostic and works natively with LangChain, LangGraph, CrewAI, Vercel AI SDK, and custom execution loops.