Skip to main content
Mocking lets you change the behavior of a Node by replacing its logic with mock code without changing the original Node settings. This approach allows you to keep the original Flow logic and mock Node behaviors to test specific Flow conditions in the Simulator, the Interaction Panel, and Endpoints without reconfiguring Nodes.

Key benefits

  • Testing Flexibility. Replace any Node’s output or function without changing Flow paths or production logic. To change the Node’s behavior, you can just activate mocking and add mock code.
  • Cost Savings. Run simulations with lower costs or less time by mocking data to avoid sending HTTP or LLM requests.
  • Consistent Testing Interactions. Control interactions for AI Agent testing by mocking LLM responses with deterministic data.

Restrictions

  • Mocking is supported only for flow agents. It isn’t available for agent targets in the Simulator.
  • If you activate mocking for a Node that has child Nodes, for example, the Then and Else Nodes of an If Node, the child Nodes aren’t executed. However, you can use mocking on child Nodes.
  • The A2A Server endpoint doesn’t support mocking.
  • Mocking isn’t available in Tool Flows.

How mocking works

Mocking adds a Mock code section to the Node editor. This section supports JavaScript code. Mock code can use the Input, Context, and Profile objects. It can also use only two API functions: api.say and api.output. Other api functions aren’t available. Learn more about the api.say function. At run-time, the mock code replaces the configured Node’s execution logic only if the Mock code field isn’t empty. If mocking is on and the field is empty, the original Node logic runs. A Node with active mocking shows an icon next to it. With the Mock code section, you can mock:
  • The AI Agent output, for example, api.say("Are there any requirements for the drilling machine?").
  • User input and data, and third-party requests, by storing data in:
    • the Input object, for example, input.text = "I would like to buy a drilling machine".
    • the Context object, for example, context.selectedProduct = "Drilling machine".
    • the Profile object, for example, profile.name = "John Doe".
If you activate mocking for Nodes that control Flow paths, for example, the If and Go To Nodes, the Flow execution is affected. This approach can lead to tests and simulations that don’t reflect your use case, for example, one of the branches of the If Node can’t be executed.

How to use mocking

To use mocking, you need to activate it at both levels: By selecting the interface for mocking, you can limit where mocking applies. For example, you can have interactions using the original Flow logic through one Endpoint and test conversations with the mock code logic through another Endpoint or in the Simulator.

Activate mocking

  1. Go to Design > Flows, select the Flow you want to test.
  2. Right-click the Node you want to mock a behavior for and select Enable Mocking. An icon such as mocking appears next to the Node to indicate that mocking is active for it.
  3. Click the Node. The Node editor opens.
  4. Expand the Mock code section and enter the mock code, for example, api.say("Are there any requirements for the drilling machine?"). Save the Node.
  1. In the upper-right corner, click interaction-panel to open the Interaction Panel.
  2. Click the Settings tab and toggle on Mocking in the Advanced section.
The Advanced section is available only for Flow targets. If the Mocking toggle is disabled, turn on advanced mode first.Now, you can run the Flow with the mock code in the Interaction Panel, both in chat and simulation modes. Mocking also applies to voice test calls made in the Interaction Panel. The setting is saved in your browser.

Deactivate mocking

To fully deactivate mocking, deactivate it at Node and interface levels. However, you can selectively deactivate mocking:
  • Deactivate mocking only at the Node level. This switches only the Node’s execution logic back to the original Node settings. If you have other Nodes with active mocking, their mock code is executed instead of the original Node settings.
  • Deactivate mocking only at the interface level. This switches the Node execution logic of all Nodes with mock code back to the original Node settings for that interface. If you have active mocking for other interfaces, the mock code is executed instead of the original Node settings.
This approach provides flexibility to easily switch between mocked and original behavior.
  1. Go to Design > Flows, select the relevant Flow.
  2. Right-click the Node you want to deactivate mocking for and select Disable Mocking.
  1. In the upper-right corner, click interaction-panel to open the Interaction Panel.
  2. Click the Settings tab and toggle off Mocking in the Advanced section.
The Advanced section is available only for Flow targets. If the Mocking toggle is disabled, turn on advanced mode first. The setting is saved in your browser.

Identify mocked responses

Mocked responses are marked, so you can tell them apart from real ones.
  • In the Interaction Panel, mocked responses carry a Mocked response badge.
  • In the Simulator, turns generated by mock code are marked Mocked response in the transcript. The simulation run list shows an icon with the tooltip “Some Nodes in this Simulation Run have been mocked.”

Examples

The following examples show how to use mock code in different cases.
To test how your AI Agent performs when it receives a predefined response from the user to a Question Node, you can mock the response. Consider that you have a Question Node that stores the user’s response in input.result. Follow these steps:
  1. Right-click the Question Node you want to mock a behavior for and select Enable Mocking.
  2. Open the Node editor, expand the Mock code section, and enter the code to mock the user’s response, for example:
To test a predefined response instead of an LLM-generated response, for example, from an LLM Prompt Node, follow these steps:
  1. Right-click the LLM Prompt Node you want to mock a behavior for and select Enable Mocking.
  2. Open the Node editor, expand the Mock code section, and enter the code to mock the AI Agent’s response, for example:
Your Flow may contain HTTP or LLM requests that may incur costs or take a long time to complete. These requests could cause issues if you test your AI Agent with frequent simulations. To avoid these issues, you can mock a request during the simulations, for example, in an HTTP Request Node. Consider an HTTP Request Node that retrieves information about a movie from the OMDB API database and stores it in the Input object under input.movie. You can mock the request of the HTTP Request Node with a predefined response. To do so, follow these steps:
  1. Right-click the HTTP Request Node you want to mock a behavior for and select Enable Mocking.
  2. Open the Node editor, expand the Mock code section, and enter the mock output, for example:

More information

Last modified on November 11, 2026