How to Get a Record from Custom Data by Search Criteria?
When your scenario needs to find an existing record (e.g. store by city, client by email, VIP by phone), use the custom_modules__get action. It searches by values from user state variables and saves the result to a variable for use in later blocks.
When Needed
- User selects a city — you need to show a list of stores from Custom Data.
- User enters email or phone — you need to check VIP status or get client data.
- You need to check if a record exists with certain values and branch the scenario accordingly.
What's Important to Know
- custom_modules__get — action for searching and getting a record from Custom Data.
- Before use, you need to save field values for search in the user state.
- Search is performed by values from variables of type "model_name:field_name".
- After getting the record, you can output its attributes in a message block.
Prerequisites
You are logged in with integrator or administrator rights. There is a created Custom Data model with records in the system. You have access to the scenario constructor. You know which fields to search by.
Step-by-Step Instructions
Preparing Search Criteria
- In the scenario, add blocks to collect data to search by:
- "Wait for Response" — for entering search value
- "Message with Keyboard" — for selection from options
- Save the value to a variable of type "model_name:field_name" (for example,
customer:email,product:code).
Example: To search by the "email" field, save the value to the customer:email variable.
Configuring Action
- Add an "Action" block to the scenario after search criteria collection blocks.
- In the "Action" block settings, select the
custom_modules__getfunction. - 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")set_to— name of the variable where the found record will be saved (for example, "customer", "found_product")
- Save changes in the action and scenario.
Using Retrieved Record
After getting 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:phone}} to output field values.
Usage Example
Scenario:
- "Wait for Response" block → user enters email, saved to
customer:email - "Action" block with
custom_modules__get→ searches for record bycustomer:email, saves tocustomer - "Message" block → outputs
{{customer:name}}and{{customer:phone}}
Typical Scenarios
| Scenario | Model fields | Sequence |
|---|---|---|
| Stores catalog | city, address, lang_code | User selects city → get by filters → show stores list |
| VIP check | email, phone, vip_status | User enters email/phone → get → show VIP benefits or standard flow |
| Categories for routing | id, first_level, last_level, name | Inline buttons with callback_data = id → get by id → route to branch |
Important Notes
- Before using
custom_modules__get, be sure to save field values for search in user state variables. - If the record is not found, the variable from
set_towill be empty. - You can use multiple fields for search simultaneously — the system will find a record that matches all criteria.
What Happens After
After executing the custom_modules__get action, the found record is saved to the variable specified in set_to. The record becomes available for use in subsequent scenario blocks. If the record is not found, the variable will be empty.
How to Verify It Worked
- Check that search values are saved to 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 is found and saved to the variable.
- Check that record attributes are available for output.
Related Materials
- Custom Data patterns and examples — how to choose the right approach
- How to create a record in Custom Data
- Use autocomplete search
- Create model