📃Module scripts
Overview
"Module scripts" can be invoked via "Go to module script" in "Actions". Unlike the usual way child scripts are used, they will, after the current flow finishes executing, continue with the subsequent flow of the main script. This characteristic can improve the efficiency and flexibility of flows, allowing you to better manage and design script flows while reducing unnecessary configuration and work.

Example scenario
For example, if you want to design an "order coffee" flow, you can split the entire flow into three regular scripts: "Send coffee items", "Confirm order", and "Complete order." All three scripts share a common flow "Check order status." No matter which script the customer is in, they can enter "check order status" or a similar keyword to obtain the latest status and related information about their ordered items. This common flow can be separated out and become a module.
Main script: Send coffee items
The bot messages the customer with selectable coffee items, including options such as coffee name, size, sweetness, and add-ons.
The customer makes selections based on the prompts, and the bot records the chosen coffee items.
Subscript: Confirm order
The bot replies with the coffee items the customer selected and asks whether the customer confirms the order.
If the customer confirms the order, the bot prompts the customer to enter order information such as name, phone number, and pickup method.
After the customer enters the order information, the bot verifies whether the order information is correct.
Subscript: Complete order
Once the order information is confirmed to be correct, the bot replies to the customer that the order is complete and provides the order number.
The bot shows the customer the order details and pickup method, and asks whether they want to continue ordering or check the order status.
Module: Check order status
When the customer enters keywords like "check" or "check order status" to obtain current or past order information.

Limitations
To avoid unexpected situations in the flow, some functions are disabled when using module scripts, such as "Go to other script" and "Transfer to human." If you need these functions, it is recommended to use the regular script type instead.
Differences from regular scripts
If you need to solve a specific problem, using a regular script is a good choice. If you need to handle complex flows and want to reuse flows more effectively, then using module scripts may be more suitable.
Invocation method
Via "Go to other script" when leaving, or as the main script.
Via "Go to module script" in Actions.
Limitations
Once you leave the current script you cannot continue back into the main script; it usually indicates the completion of a major section.
Cannot perform actions such as "Go to other script", "Transfer to human", or invoking "Go to module script" again.
Usage
Responsible for completing a specific task, such as keyword handling or calling APIs. Compared to module scripts, it is more independent and does not need to rely on other scripts to run.
Break a complex flow into multiple smaller segments, each of which can be used independently in different scripts, making the overall flow more modular and flexible.
Last updated