Collect Node
Overview
The Collect Node is utilized to interactively collect data from users via configured slots, which capture necessary information within the workflow.
Configuration
Adding and Editing Slots
Users can define slots to collect specific data from user inputs. Each slot can be customized with the following attributes:
- Label: A user-friendly name. (Also fallback for
Description
) - Key: A unique identifier used programmatically to reference the collected data.
- Type (optional): Specifies the data type of the slot. Choices include:
String
(default)Number
Enum
for predefined values
- Pattern (Regex) (conditional): A regular expression for validating data, applicable if the slot type is not
Enum
. - Options (Enums) (conditional): Specifies allowed values for the slot, required if the type is
Enum
. - Description (optional): Provides a brief instruction for the LLM on how to handle the slot, aiding in generating appropriate user prompts.
Settings
Configurable settings include:
- Connection: Selects the model connector for processing the data
- Model (LLM): Specifies the large language model to use for processing the data. Model availability depends on the selected connection.
- Assistant ID (conditional): Required if using a specific assistant configuration with models like
gpt4-assistant
. - Language (optional): Sets the default language for interactions. Not available in
Custom Prompts
- Custom Prompt (optional)
Custom Prompt
Provides a JavaScript function that customizes the System Prompt
handed to the configured Model
. It uses the following parameters:
- items[]: An array of the configured slots within the node.
- globalData: Contains all previously collected data from other nodes. (object)
- tone: Can be
impersonal
,formal
, orpersonal
, directing the tone of the interaction.
Example of a custom prompt function:
(({items, globalData, tone}) => `Always format your response in JSON with the schema {slots: {[id]: value}, message, status}.
Request the following slots from the user:
${JSON.stringify(items)} while keeping a ${tone ?? "formal"} tone.
If done, status is DONE.`)({items, globalData, tone})
It is generally advised to use the proven default prompt.
Output Schema
The custom JavaScript function should output an object adhering to this schema:
- slots: Key-value pairs where keys are slot IDs, and values are the data collected for those slots.
- message: Output to user.
- status: Indicates whether the interaction is complete (
DONE
) or ongoing (IN_PROGRESS
).
Example responses
The following displays valid responses, resulting from input handling.
Request name
{
"slots": {},
"message": "Please tell me you name.",
"status": "IN_PROGRESS"
}
Confirm input
{
"slots": {"name": "Jon Doe"},
"message": "Thank you!",
"status": "DONE"
}
Output
Emits the results from data collection to subsequent nodes.
Language
Language set within conversations will always be output to globalData
slot _language