Subflows are reusable 'Functions' within a skill that perform a specific task as part of a conversation. These promote reusability by allowing these functions to be utilized across multiple skills, thereby enhancing efficiency and consistency in the development process. Using sub-flows aids advance skill creation in the following ways:
Efficiency: Subflows eliminate the need to branch to different skills conditionally, allowing for conditional execution of actions within the main skill and then continuing with the remaining steps.
Reusability: They promote the reuse of functionalities across various skills, reducing redundancy in development efforts.
Consistency: By using subflows, developers can ensure consistency in executing specific tasks across different parts of the conversation.
For example, if the main skill is 'Create a new account in AD,' corresponding sub flows such as 'Check for Existing User,' 'Generate Unique ID,' and 'Create Account' can be created. Each sub-flow executes a specific task without branching out of the main skill.
SubSkill vs. Subflow
Sub Skills and Sub Flows are crucial in improving the modularity, reusability, and efficiency of Skills. They enable developers to break down complex functionalities into smaller, manageable units, fostering consistency and scalability in conversational experiences. Here are the key differences between Sub Skills and Sub Flows:
Control Flow: When branching to a sub-skill, control permanently shifts from the main skill to the sub-skill, and the main skill doesn't regain control automatically. In contrast, a sub-flow functions like a subroutine within the main skill. After the Sub Flow's execution, control returns to the main skill, allowing the conversation to resume where the Sub Flow was invoked.
Execution Behavior: A Sub Skill can execute another Sub Skill, Skill, or Sub Flow, permanently branching the conversation flow. On the other hand, a subflow cannot execute another subflow but can branch permanently to a Skill or Sub-skill.
Reusability: While both Sub Skills and Sub Flows can be reused across different skills, they differ in their execution and control flow. Sub Skills achieve reusability by creating modular components usable across various conversational scenarios, while Sub Flows promote reusability by encapsulating specific functionalities or tasks within a skill.
Invoking: Sub Skills cannot be triggered independently using user phrases. Instead, it's invoked programmatically based on predefined conditions or from a Card or Quick Reply Message during the conversation. Similarly, sub-flows are not triggered independently by user phrases but are invoked within the main skill's flow based on the conversation context. Unlike Sub Skills, Sub Flows cannot be invoked from a Card or Quick Reply Message.
Creation and Management
Subflows can be managed under the Subflows section within Bot Builder. The creation process is similar to creating a skill in Visual Designer, with all the controls available for skill building also applicable to subflow creation. For more information on subflow controls refer to Building Conversation in Visual Designer
Create a New Subflow
Subflow creation is essentially similar to Skill creation. It uses the visual designer to connect various conversation items and create a conversation flow within the subflow.
To create a SubFlow, do the following:
- On the Skill Builder page, Navigate to Subflow, and click Create Subflow.
- Specify the Subflow Name, Description, and Category. The system automatically suggests an Identifier, which can also be edited.
- Build the conversation flow in the visual designer canvas. Drap and drop the controls from the palette and connect to build a conversation between the user and the bot. To learn how to build a conversation flow, see Create Skills.
- Click Save.
The Subflow is created.
Another way to create a subflow is by using the steps in an existing skill:
- Navigate to the skill builder and open the required skill.
- Select one or more steps in the skill using Ctrl+Select or Shift+select.
- Click on the Create Subflow option.
- On the pop, Specify the Subflow Name, Description, and Category. The system automatically suggests an Identifier, which can also be edited.
- Click Create.
- The steps are copied to the canvas. Connect the steps to the START control to build the flow.
- Click Save.
The Subflow is created.
- Execution of a Subflow from a subflow is not allowed. 'Execute Subflow' step is not available in the palate within a Subflow.
- When copying steps to create a subflow, START and Execute Subflow steps are not copied.
Execute Subflow
This action is used within a skill to execute a subflow, allowing for executing specific functionalities defined as part of the Subflow.
Use the Conversation step and execute Subflow in Visual Designer. For more information, refer to Execute-Subflow
- SubFlows can only be triggered by other skills and not by user phrases.
- Permissions and Reprompting behavior are inherited from the main skill. If the user has permission to use the parent skill, they can use the Subflow.
- Once the Subflow execution is complete, the control returns to the main skill, resuming execution from the branching step.
Click on the START step in the subflow to view workflow usage. Here, you can view the list of skills and the number of occurrences i.e. number of times the subflow is used in each of the skills.