This guide assumes familiarity with the following information:
Response node (Creating a Bixby Response Using Device Status)In this guide, you'll learn how to use the Subgraph feature to modularize a graph and separate functionality into distinctive and reusable sections. This feature also reduces the complexity of a graph. For example, you can create a subgraph to calculate a conversion, check a specific attribute like if the power is on, or get date information.
You'll also learn how to do the following:
Start Subgraph, Calculation, SetReturn SubGraph, and End Subgraph nodes.Call Subgraph node.The device used in this guide is a simulated thermostat. The example utterance "Set the cooling temperature of the thermostat to 23 degrees celsius" will be used to design an action flow for this voice command, which includes a subgraph that converts an input temperature value from Celsius to Fahrenheit. This will allow Bixby to set the thermostat's cooling temperature to the Fahrenheit equivalent of the Celsius input.
First, add a subgraph to the metadata.
In order to create and use a subgraph with your device, you have to add the subgraph to the Sub Graph Manifest in the metadata sidebar.
In the metadata sidebar on the left, click the add icon
on the right of Sub Graph.
A pop-up for the Sub Graph Manifest appears.

Next, customize the subgraph.
This section defines the parameters being passed to your subgraph and what information is returned by it.
ToFahrenheit. This name shows up under the Call Subgraph node, which will be called in the main graph.

TempInCelsius. Each parameter you add becomes an input port on the Call Subgraph node.Integer.

main. Each trigger you add becomes a trigger port on the Call Subgraph node.


Now, you can create an action flow for the subgraph using relevant nodes.
Subgraphs can be used in any main graph. With a subgraph, you can perform all functions available in a main graph, with the exception of creating Bixby responses. The subgraph editor doesn't have Response nodes.
Start Subgraph node, which initiates the execution of a subgraph's action flow.Start Subgraph node with a default parameter value by clicking on the node and typing the value under the appropriate parameter. This example uses the parameter value 23 for the TempInCelsius parameter.

Command or Set Variable. This example uses a Calculation node configured with the mathematical expression for converting a Celsius temperature value into a Fahrenheit one.

SetReturn SubGraph node, which sets the value the graph will return.SetReturn SubGraph node with appropriate information. This example uses value as the returnName.

End Subgraph node, which sets the port to trigger upon completion of subgraph execution.End Subgraph node with appropriate information. This example uses main as the triggerName.


Next, test your subgraph.
To test the action flow, click the Try It button at the top right of the editor window. The flow editor should look like this:

In this example's test run, Bixby first fetches the input value, which is 23 degrees Celsius. Then, Bixby uses the mathematical expression (C * 9/5) + 32 to convert 23 degrees Celsius to 73.4 degrees Fahrenheit. Then, Bixby returns the value of 73.4 and the execution process finishes.
You can now use the subgraph in your main graph's action flow.
Incorporating a subgraph helps reduce the complexity of a main graph by allowing one node, Call Subgraph, to fetch the value returned from the operation performed in a specific subgraph.
To incorporate a subgraph into your main graph's action flow, do the following:
Start node.Start node with default parameter values. This example uses a default integer value of 23 for thecoolingTemperature parameter and a default string value of c for the predefinedCoolingTemperatureUnit parameter.

Call Subgraph node, which invokes a specified subgraph.Call Subgraph node by clicking on the node and selecting a graphId from the menu. This example calls the ToFahrenheit Sub Graph created earlier.

Response: Success node.ToFahrenheit Sub Graph:

To test the action flow, click the Try It button at the top right of the editor window. The flow editor should look like this:

In this example's test run, Bixby first fetches the input value, which is 23 degrees Celsius. Next, Bixby fetches the value returned from the subgraph, which is 73.4 degrees Fahrenheit. Then, Bixby sets the device's cooling temperature to 73.4 degrees Fahrenheit. Finally, Bixby responds to the user by saying "SUCCESS."