Chain Commands - Documentation

Build complex automation sequences from simple building blocks using the visual logic editor.

In all URLs below, replace XXX with your AI Apps Account ID, found in your account settings.

What Are Chain Commands?

Overview of automation sequences and when to use them
Show / Hide
A chain command is a sequence of actions that runs from a single trigger. Instead of making one API call that does one thing, a chain command lets you combine multiple actions into one automated workflow. The sequence can call any of your installed apps, call external APIs, make AI requests, store and retrieve data, and use conditional logic to change what happens based on the information it receives along the way.
How it works:
You start by sending one API call or triggering a webhook. That initial request includes whatever data you want to pass in -- a customer ID, a message, a form submission, or anything else. The chain command takes that data and runs through a series of steps you designed in the visual editor. Each step can call another API, check a condition, set a variable, or end the chain with a result. The output from one step can feed into the next, so information flows through the entire sequence.
When to use chain commands:
Use chain commands when a single action is not enough. For example: a new customer signs up, and you want to create their profile, send a welcome email, add them to an SMS list, and notify your team -- all from one trigger. Or a chatbot receives a question, and you want to look up the customer's order history, run an AI query with that context, and log the interaction. Any time you need multiple things to happen in order, with decisions along the way, chain commands handle it.
Chain commands can call any command from any app you have installed, including other chain commands. This means you can build small reusable sequences and nest them inside larger workflows.

The Visual Logic Editor

How to build and edit command sequences
Show / Hide
The chain command editor is a visual drag-and-drop canvas where you build your automation sequences. Each step in the sequence is a node on the canvas, and you connect nodes together by drawing lines between their output and input ports. The flow runs from top to bottom, starting at the Request Start node and following the connections you create.
Editor controls:
Double-click anywhere on the canvas to add a new node.
Hold left-click and drag to move a node around the canvas.
Right-click a node to delete it.
Click and drag from an output port to an input port to connect two nodes.
All changes save automatically as you work.
The Request Start node:
Every chain command begins with a Request Start node. This is created automatically when you open a new flow. It represents the initial trigger -- the API call or webhook that starts the chain. All variables you defined for this command are populated from the fields in the initial request. From here, you connect to the first action node in your sequence.
No programming is required. The visual editor handles all the logic. You simply choose what type of action each node should perform, fill in the fields, and connect the nodes in the order you want them to run.

Node Types

The building blocks of every chain command
Show / Hide
When you add a new node to the canvas, you choose its type. Each type serves a different purpose. Together, these node types can handle any automation scenario.
Internal App Command
Calls any command from any app installed on your account. You select the app, then select the command, and the editor pre-fills the expected fields. This is how you connect your chain to chatbots, email broadcasts, SMS broadcasts, AI bots, or any other app. The fields use the same variable system -- type {variableName} to pass a variable value into any field. The return fields capture values from the response back into your variables for use in later nodes.
External API Call
Sends an HTTP request to any URL. You enter the API URL, choose the post method (form post or JSON), define the fields to send, and specify which response fields to capture back into your variables. Use this to connect to any third-party service, your own servers, or any external system that accepts HTTP requests.
Conditional Statement (If/Else)
Checks a variable against a value and branches the flow in two directions: True or False. Supports these conditions: equals, not equal, greater than, greater than or equal, less than, less than or equal, character length greater than, and character length less than. The comparison value can be a fixed value or another variable using the {variableName} syntax. Connect different nodes to each output to handle each case.
Switch Statement
Routes the flow to one of many branches based on a variable's value. You define named cases, and each case gets its own output port. If the variable matches a case value, that branch runs. If no case matches, the default branch runs. Use this when you need more than two possible paths -- for example, routing by status, category, or response type.
Set Variable
Assigns a new value to a variable. You pick the variable and enter the new value, which can be a fixed string or a reference to another variable. Use this to prepare data for the next step, combine values, or reset a variable between actions.
End Nodes (Success, Fail, Error, End)
Terminates the chain and returns a result. Success and End return a success message. Fail and Error return an error message. You can customize the message for each end node. Every branch of your flow should eventually reach an end node so the chain knows when it is finished and what to report back.
Each node can connect to one or more nodes after it. Conditional nodes have two outputs (True and False). Switch nodes have one output per case plus a default. All other nodes have a single output that connects to the next step.

Variables and Data Flow

How information moves through a chain command
Show / Hide
Variables are the data containers that carry information through your chain. When you create a command, you define its variables in the command settings. These variable names become available in every node in the flow. When the chain starts, each variable is populated from the matching field in the initial API request. If a field was not included in the request, the variable starts as empty.
Using variables in node fields:
Anywhere a node accepts input, you can type a variable name wrapped in curly braces: {variableName}. When the node runs, the system replaces the placeholder with the current value of that variable. This works in internal app command fields, external API post fields, conditional comparison values, and set variable values.
Capturing output with return fields:
When an internal app command or external API call returns a response, you can map fields from that response back into your variables using return fields. The format is variableName={responseField}. The system searches the response for the named field (even in nested data) and stores the value in your variable. This is how the output of one step becomes the input for the next.
Example flow:
1. A request comes in with customerEmail and question.
2. An internal app command calls the chatbot with {question}, and the return field captures the response into aiReply.
3. A conditional checks if {aiReply} length is greater than 0.
4. If true, an email command sends {aiReply} to {customerEmail}.
5. The chain ends with a success node.
Variables are shared across all nodes in the chain. When a Set Variable node or a return field updates a variable, every node that runs after it sees the new value. Plan your variable names carefully so they are clear and do not accidentally overwrite each other.

Admin: Managing Commands

Creating and configuring chain commands in the admin panel
Show / Hide
The command list page shows all chain commands you have created. From here you can create new commands, edit existing ones, or open the visual editor to build the flow for any command. Each command is an independent automation sequence with its own name, variables, and flow.
Command Settings
FieldDescription
Name The display name for this command. Used to identify it in the admin panel and flow editor.
Status Enable or disable the command. Disabled commands cannot be triggered.
Automatic Schedule Optional schedule to run this command automatically on a timer. Uses the platform's cron system to trigger the command at set intervals without an external API call.
Notes Optional internal notes about what this command does. Not used in execution.
Allow Webhook When enabled, this command can be triggered by posting directly to its webhook URL without an API key. See the Webhook section below for details.
Sequence Variables The list of variable names used in this command's flow. Add every variable your nodes will reference. These are populated from the initial request and shared across all nodes. Use only letters and numbers in variable names.
After creating a command and defining its variables, click the command name on the flow editor page to open the visual canvas and build the sequence. The command will not do anything until you add nodes to its flow.

How Endpoints Work

Two ways to call each endpoint - read this first
Show / Hide
App Command (API Call)
POST your request to https://api.aiappsapi.com with your API key and account ID in the POST body. The fields described in each section below go inside the jsonData POST field as a JSON-encoded string. Use this method when your server is making the call and you have your API credentials available.

Mode / Webhook (Direct URL)
POST directly to the endpoint URL shown in each section. The fields go in the POST body as standard form fields (the same fields you would include in an HTML form POST). Use this method for provider webhooks, website forms, or any third-party system that sends form data. No API key is required -- the account ID is part of the URL.

Run Command

command: runcommand
Show / Hide
Triggers a chain command to execute. The command runs through the entire flow you built in the visual editor, executing each node in sequence. The response includes a summary of how many actions ran and the final status (success or error) from the end node the flow reached.
POST App Command URL
https://api.aiappsapi.com     app: chaincommands     command: runcommand

Required Fields
Field NameField KeyNotes
Command ID commandID The ID of the chain command to run. This is the index of the command in your command list, visible in the admin panel.
Optional Fields
Field NameField KeyNotes
Command Variables (variable names) Include any fields that match the variable names defined in the command. For example, if the command has variables customerEmail and message, include those as fields in your request. Any variable not included in the request will start as empty.

Webhook

mode: webhook
Show / Hide
Triggers a chain command via a direct URL without an API key. The command must have "Allow Webhook" enabled in its settings. Use this when you want an external service, form, or third-party system to start a chain command by posting data directly to a URL.
POST Webhook URL
https://api.aiappsapi.com/XXX/chaincommands/webhook

Required Fields
Field NameField KeyNotes
Command ID commandID The ID of the chain command to run. The command must have "Allow Webhook" enabled or the request will be rejected.
Optional Fields
Field NameField KeyNotes
Command Variables (variable names) Include any fields matching the variable names defined in the command. These populate the command's variables at the start of execution.
The webhook endpoint runs the exact same flow as the Run Command API call. The only difference is the calling method -- no API key is required, but the command must have webhook access enabled.