Storing data across executions

Many connectors used in channel workflows allow data to be stored and retrieved across executions, over the course of a conversation.

Channel workflows allow actions and logic to be performed in response to an incoming message from a client (e.g., from WhatsApp or a web widget). For workflows that only reply to the user with output (e.g., only using "Send a Message" connectors), the conversation can be completed in one execution. However, if the workflow prompts the user for further input (e.g., using the "Ask a Question" or "Multiple Choice" connectors), the execution of the workflow will be stopped midway to wait for the user's reply.

When the user replies, a separate execution will be started at the point where the previous execution left off, with the user's reply provided in the output of the connector where execution continues. However, the output data from earlier connectors in the previous execution is no longer available in the new execution.

"Clip and Cache" and "Prep and Send" connectors

In order to allow for data to be persisted across executions for the same conversation, two dedicated connectors are provided to store and retrieve data.

The "Clip and Cache" connector allows JSON data to be stored under a label of your choosing. The data stored is specific to the conversation with the given user (each separate conversation can be viewed in the Conversations tab of the iMBrace app).

Example usage of Clip and Cache connector.

The "Prep and Send" connector can be used to retrieve the stored data in subsequent executions, using the same label that was used to store the data previously. The stored data will be made available in the output of the connector under the label that was used to store it (in this example, the value can be accessed as $json.my_label).

Example usage of Prep and Send connector.

In order to persist data across executions, the "Prep and Send" connector should be used before any connector that stops the execution for user input, and the "Prep and Send" should be used when the data is needed.

circle-info

Note that since the output of the "Prep and Send" connector is not preserved across executions, you may need to use the "Prep and Send" connector for the same label multiple times, depending on the structure of your workflow.

Example usage within a workflow to persist data across executions.

"Save Answer" option

Many connectors that prompt for user input (e.g., "Ask a Question" and "Multiple Choice" connectors) include a "Save Answer" option to automatically store the user's reply under a specified label. This functions the same way as using the "Clip and Cache" connector. Data stored using this option can be accessed in the same fashion by the "Prep and Send" connector.

Last updated