Skip to main content
The Output Transformer converts the Flow output. This transformer allows you to manipulate the Flow output before it’s sent to the Endpoint. You can configure the output transformer in the handleOutput function in the Endpoint settings or via CLI. The output transformer works differently for the following Endpoint types:
  • REST-based Endpoints
  • Webhook- and Socket-based Endpoints
When using output transformers in REST Endpoints, you can’t send multiple Flow outputs to the user. However, you can still have multiple Say Nodes in a Flow that are triggered by each user input.In this case, the handleOutput function stores the Say Node outputs in the outputs array. You can process the stored outputs with the execution finished transformer, which concatenates them into one output when the Flow execution has finished. This approach allows you to manipulate each Flow output in the handleOutput function and then concatenate them into one output with the execution finished transformer.

Transformer Function Arguments

Depending on the Endpoint type you are using, the function arguments vary:
  • REST-based Endpoints
  • Webhook- and Socket-based Endpoints
ArgumentDescription
endpointThe configuration object for the Endpoint.
outputThe raw output from the Flow.
userIdThe unique ID of the user.
sessionIdThe unique ID of the session.

Endpoint Configuration Object

PropertyTypeDescription
_idstringThe Endpoint’s Reference ID.
channelstringThe Endpoint’s channel.
URLTokenstringThe URL Token, found in the Input object.
namestringThe Endpoint’s name.
flowIdstringThe Reference ID of the specified Flow to which the Endpoint points to.
entrypointstringThe Entrypoint of the Endpoint.
activebooleanThe flag to activate or deactivate the Endpoint.
nluConnectorIdstringID of the selected NLU connector for the Endpoint.
useAnalyticsbooleanThe flag to collect analytics data for the Endpoint.
storeDataPayloadbooleanThe flag to store data payloads into analytics for the Endpoint.
useConversationsbooleanThe flag to collect conversations history for the Endpoint.
maskIPAddressbooleanThe flag to mask sensitive IP addresses in input object and analytics data.
maskAnalyticsbooleanThe flag to mask sensitive data in analytics for the Endpoint.
maskLoggingbooleanThe flag to mask sensitive data in logs for the Endpoint.
useContactProfilesbooleanThe flag to use Contact Profiles for the Endpoint.
useDashbotAnalyticsbooleanThe flag to use Dashbot for collecting analytics data.
dashbotApikeystringThe API key of the Dashbot bot for analytics collection.
dashbotPlatformstringThe selected platform of the Dashbot bot for analytics collection.
settingsobjectOptional Endpoint-specific settings. For example, Facebook Page token.
handoverSettingsobjectSettings to configure a handover provider.
createdAtnumberUnix timestamp when the Endpoint was created.
lastChangednumberUnix timestamp when the Endpoint was last modified.
createdBystringEmail of the user who created the Endpoint.
lastChangedBystringEmail of the user who last modified the Endpoint.

Return Values

The output transformer return value depends on the Endpoint type in which you use the transformer. There is no validation of the output transformer return value. If the output transformer returns a falsy value, the output is discarded and not stored in the outputs array.
  • REST-based Endpoints
  • Webhook- and Socket-based Endpoints
The handleOutput function returns a value and stores it in the outputs array. You can access this array with the handleExecutionFinished function. You can set the format of the outputs array items in the handleOutput function. By default, the outputs array entries have text and data properties. You can change the output format as follows:
handleOutput: async ({ processedOutput, output, endpoint, userId, sessionId }) => {
const modifiedOutput = {
    text: "text",
    data: {}
    // ...
};

return modifiedOutput;
}
I