Actions40
- AI Actions
- Business Actions
- Calculate Actions
- Code Actions
- Convert Actions
- Crypto Actions
- Generate Actions
- Operator Actions
- PDF Actions
- Storage Actions
Overview
The Operator → Advanced Switch operation in this custom n8n node allows you to perform advanced conditional logic (switching) based on keys and values from a JSON object. You can either provide the JSON data directly or fetch it from an external URL. This is useful for dynamic routing, decision-making, or branching workflows based on complex, multi-key conditions.
Common scenarios:
- Routing workflow execution paths based on multiple criteria.
- Dynamically selecting actions or outputs depending on structured input data.
- Centralizing switch/case logic using external configuration files.
Practical example:
Suppose you have a JSON file with user roles and permissions. You can use this node to check multiple keys (e.g., "role", "department") and route users accordingly.
Properties
| Name | Meaning |
|---|---|
| External JSON? | If enabled (true), the node will fetch the JSON data from a provided URL. If disabled (false), you must provide the JSON content directly. |
| Url | The URL to fetch the JSON data from. Only shown if "External JSON?" is true. |
| Content | The stringified JSON data to use. Only shown if "External JSON?" is false. Must be valid JSON as a string. |
| Keys | List of keys to evaluate, one per line. These are used to determine how to switch/route the logic. |
Output
The output will be a JSON object (or array of objects) containing the result of the advanced switch operation. The structure depends on the specific logic implemented by the backend service, but typically includes:
- The evaluated keys and their corresponding values.
- The matched case or branch, if applicable.
- Any additional data resulting from the switch logic.
If an error occurs (and "Continue On Fail" is enabled), the output will include an error field with the error message.
Example output:
{
"matchedCase": "admin",
"values": {
"role": "admin",
"department": "IT"
}
}
Dependencies
- External Service: Requires access to the CodeKit API (as indicated by the required
codeKitApicredential). - API Key/Credentials: You must configure the
codeKitApicredential in your n8n instance. - Network Access: If using "External JSON?", the node must be able to reach the specified URL.
Troubleshooting
Common issues:
- Invalid JSON: If "Content" is not valid JSON, the node will throw a parsing error. Ensure your JSON is properly formatted and stringified.
- Unreachable URL: If "External JSON?" is enabled and the URL is invalid or unreachable, the node will fail to fetch the data.
- Missing Keys: If the specified keys do not exist in the JSON, the output may not match any case or could return unexpected results.
Error messages:
"Unexpected token ... in JSON at position ...": Indicates malformed JSON in the "Content" property. Validate your JSON before submitting."Request failed with status code ...": Indicates a problem fetching the external JSON (e.g., network issue, wrong URL, server error).
How to resolve:
- Double-check your JSON syntax using a validator.
- Ensure URLs are correct and accessible from your n8n environment.
- Make sure all required properties are filled in according to your switching logic.