How to Use custom_modules__set Action to Create a Record?
The custom_modules__set action creates a new record in a Custom Data table. All input blocks before this action collect user data and save it to variables, which are then used to create the record.
When Needed
- You need to create a new record in a Custom Data table based on data entered by the user.
- You need to save complex information about a user or interaction.
- You need to automatically create records after collecting data in a scenario.
What's Important to Know
- custom_modules__set — action for creating a new record in Custom Data.
- All input blocks before this action collect data and save it to variables of type "model_name:field_name".
- After creating the record, it is saved to the variable specified in the
set_toparameter. - Used for creating new records, not for updating existing ones.
Prerequisites
You are logged in with integrator or administrator rights. There is a created Custom Data model with needed fields in the system. You have access to the scenario constructor. You have collected data from the user in previous scenario blocks.
Step-by-Step Instructions
Preparing Data
- In the scenario, add blocks to collect data from the user:
- "Wait for Response" — for text input
- "Message with Keyboard" — for selection from options
- Make sure data is saved to variables of type "model_name:field_name" (for example,
customer:name,customer:email).
Configuring Action
- Add an "Action" block to the scenario after data collection blocks.
- In the "Action" block settings, select the
custom_modules__setfunction. - In the configuration field (JSON), enter parameters:
{
"module_name": "customer",
"set_to": "customer"
}
module_name— name of the model with the custom table (for example, "customer", "product", "order")set_to— name of the variable where the created record will be saved (for example, "customer", "new_order")
- Save changes in the action and scenario.
Using Created Record
After creating the record, you can output its attributes in a message block using the variable from set_to. For example, if set_to = "customer", you can use {{customer:name}} or {{customer:email}} to output field values.
Usage Example
Scenario:
- "Wait for Response" block → saves to
customer:name - "Wait for Response" block → saves to
customer:email - "Action" block with
custom_modules__set→ creates record and saves tocustomer - "Message" block → outputs
{{customer:name}}and{{customer:email}}
What Happens After
After executing the custom_modules__set action, a new record is created in the Custom Data table with all data collected in previous blocks. The record becomes available for viewing in the Custom Data module and can be used in other parts of the scenario through the variable from set_to.
How to Verify It Worked
- Check that all data is collected in variables of type "model_name:field_name".
- Make sure the model name in
module_namematches an existing model. - Test the scenario and check that the record was created in Custom Data.
- Check that the variable from
set_tocontains the created record.