Additional Settings for Complex Nodes

Most complex processes and state diagrams make use of the Code, API Calls, Call Process, Reply to Process, Queue, and Get from Queue nodes. Basic settings are described in Node Basics and this page only covers settings unique to each node.

Code

The Code node allows you to execute JavaScript or Erlang code within a node. It consists of a Code node, a Delay node, and a Condition node working together to run the code. The Delay node is used as a circuit breaker, to limit the time that your code can run, and the Condition node catches errors in your code.

We recommend working on your code in a code editor and pasting it into the node. The Mambu Process Orchestrator (MPO) UI offers only basic validation.

The settings of the MPO Code node Enter your code into the window provided. You can expand the window by selecting the fullscreen icon in the corner of the code window.

The expanded Code Editor

JavaScript

Code verification in the MPO UI will show errors for ES6 syntax or later. To turn off warnings when you use ES6 syntax such as map(), filter(), and other functions, add / * jshint esnext: true * / in the first line of your code.

To use task parameters as variables within your code, affix them after data..

Example

If we had a declared parameter called server with the value mambu, the following code prints the value mambu to the console.

console.log(data.server);

JavaScript libraries

The following libraries are included in MPO by default:

Erlang

Task parameters in Erlang code are created or modified with a specifying module of any name and one main function export.

Example

The code block below adds the server parameter to a task.

-module(node).
-export([main/1]).
main(Data) -> [{<<"server">>, <<"mambu">>} | Data].

Error responses

Return Type TagReturn Type DescriptionReturn Type ErrorCause
code_executing_errorerror_textsoftwareError in the entered code.
code_timeoutTimeout for executing codehardwareThe execution of the custom code timed out. The maximum execution time is 5 seconds.
code_return_format_errorerror_textsoftwareThe code reply is in the incorrect format.

API Call

This node allows you to make API calls to external services using JSON, XML, or SOAP. A Delay and a Condition node are included automatically when you add an API Call node. These nodes handle errors that may arise when making calls. The Condition node determines the type of error returned and depending on the error, continues to either the Delay node to try again or ends the task with an error.

MPO API Call node configuration settings

OptionDescriptionValueRequired
URLThe URL to retrieve data. You may use parameter values to include path parameters.URL beginning with https:// or http://Yes
Request formatThe format of the request.Default, Corezoid, or Raw.Yes
Request methodThe action of the request.GET, POST, PUT, DELETE, HEAD, or PATCHYes
Content-TypeDefines what data format is being transferred in the request.application/json, application/x-www-form-urlencoded, application/xml, text/xml, or application/soap+xmlYes

Parameters

You can use parameters to declare the body of the API request or use them as path parameters in the request URL.

Additional settings

There are further options in the Additionally section, where you can:

  • Set header parameters using key-value pairs.
  • Customize the response parameter.
  • Limit the number of simultaneous requests to the API. The default value is 5. For connectors that require high concurrency, the setting can be increased to values as high as 5,000 or 10,000. But this will affect the number of threads that MPO can spin up to handle outgoing API requests.
  • Use system parameters as path parameters in the request URL by enabling Send system parameters.
  • Sign the request by secret key.
  • Sign the request with a certificate.

Error responses

API calls return a response code that looks like the below:

{
    "__conveyor_api_return_description__": "Not valid http result json",
    "__conveyor_api_return_http_code__": 405,
    "__conveyor_api_return_type_error__": "software",
    "__conveyor_api_return_type_tag__": "api_no_valid_json"
}

To debug an API call, find the right return HTTP code, return type error, and return type tag to diagnose the cause.

Return Type TagReturn Type DescriptionReturn Type ErrorCause
api_bad_answerno_schemesoftwareThe API URL is empty.
api_bad_answertimeout or failed_connectsoftwareAPI call timed out. The maximum time to wait for an API response is 60 seconds.
api_bad_res_dataBad res_data: ", Data/binary, ". Please check documentationsoftwareThe API reply contains the wrong res_data.
api_bind_errorError bind params to http queryhardwareFailed to add the parameters to the query.
api_expire_queryExpire task to API, please check your api for correct answer, or increase max_threads for connectionshardwareAll connections to the API have been used or the API has not answered for a long time.
api_fatal_errorError running apihardwareAn internal process error.
api_no_opsNo ops. Please check documentationsoftwareThe API response does not contain an ops block
api_no_request_procBad request_proc tag. Please fill request_proc=ok for your answer. If you want to put error use proc!=oksoftwareThe wrong request_proc in reply
api_no_valid_jsonNot valid http result json.softwareThe request’s JSON body is invalid.
api_task_size_overflow_limitYour task size: {{size_data}} bytes, Max available task size: 128000 bytes, Try to change your data or try to split your task.softwareThe API response is bigger than 128kb.
api_wrong_convert_paramParam: ___, Value: ____, Try convert to:softwareFailed to convert the returned parameters. This may happen when the parameters are not XML, JSON, or images.

The API’s HTTP response code provides the value for the "__conveyor_api_return_http_code__" key. If there are connection failures or other network issues, the HTTP code will be 0. If a successful API response contains an array, the node will return the __conveyor_api_array__ object. For more on how to use and extract data from this object, see Using the returned data.

Call Process

The Call Process node makes a synchronous call to a process to upload a task and waits for a response from that process, which will use the Reply to Process node to send back a response. To specify the process that you want to call, you must add either the Process ID or the Alias in Basic Settings > Alias or process. This will upload a new task to that process.

To send the current processes parameters to the called process, select Send all parameters. You can also declare parameters to send at this stage by selecting + Add “Key-value” or adding a JSON object in the Code editor.

Error responses

ParameterDescriptionCause
__conveyor_copy_task_result__crash_apiThere was an error calling the process.
__conveyor_copy_task_result__access_deniedThe user does not have access rights to the called process.
__conveyor_rpc_return_type_tag__rpc_task_fatal_errorThere was an error calling the process.
__conveyor_rpc_return_type_tag__rpc_task_size_overflowThe returned data exceeded 128kb. Try splitting your task or filtering the returned data down.
__conveyor_rpc_return_type_tag__rpc_task_wrong_convert_paramThe returned parameters cannot be converted to their specified type.

Reply to Process

In order to return a response you need to add the Reply to Process node to the called process. You would add this node before every end node of the call process to ensure that a processed response is received by the calling process. In the Parameters section you define the parameters you want to return to the calling process.

The settings for the MPO Reply to Process node

Queue

The Get from Queue node gets the task queue and parameters for a process. It is useful for getting data about tasks uploaded to other processes. In order to set it up, you need to add a Queue node to the process you want to get data from and a Get from Queue node to the process receiving the data. Placing the Queue node after the Start node allows you to register all the tasks uploaded to the process. The task queue is stored in the node and sends data when called by a Get from Queue node in a process.

Get from Queue

The Get from Queue node fetches data from a Queue node in another process. To set up the node you need to specify the Alias or process and the Queue node in the corresponding process in the Node input.

The returned object looks like this:

{
    "__queue_task_data__": {
        "{{some_key}}": "value1",
        "{{some_key2}}": "value2"
    },
    "__queue_task_id__": "61693f97bf8a640017001203"
}

The "__queue_task_data__" object contains all the tasks parameters from the Queue node and the value of the "__queue_task_id__" key is the task ID.

Error responses

Return Type TagReturn Type DescriptionReturn Type ErrorCause
get_task_executing_errornot_found_tasksoftwareThe are no tasks uploaded to that process.
get_task_executing_erroraccess_deniedsoftwareThe user does not have access to the process with the Queue node.
get_task_fatal_errorError running get taskhardwareAn internal server error.
get_task_wrong_convert_paramsoftwareInvalid transferred process ID or node for dynamic use. Check that the process and node you picked in the Get from Queue node are correct.
queue_wrong_logicNo queue logic in conv_id:softwareThe Queue node is missing from the process you want to get data from.