This guide assumes familiarity with the following information:
CommandNode (Sending a Device Command)
ConstantNode (Creating a Bixby Response Using a Device Status)
Equal ComparisonNode (Concatenating Actions)
ResponseNode (Creating a Bixby Response Using a Device Status)
In this guide, you'll learn how to get specific values in a usable format from raw JSON data using the
JSON Query Node. The device used in this guide is a SmartThings-enabled speaker.
Example: "Increase the volume of the speaker by 50."
For this voice command, you must get the result of a command and give the user the information. Sometimes the output of nodes (responses) are in JSON format. To extract information from these responses, you can use the
JSON Query Node.
To start extracting information, you first need to build your action flow with a
Start Node and a
Command Node, like in the Sending a Device Command guide.
StartNode's main port to the
CommandNode's trigger port, and the
StartNode's volumeLevel value port to the
CommandNode's Level port.
JSON QueryNode to open the node configuration menu on the right.
dataType"String." This pointer value selects the
statusproperty of the "results" and parses the
statusproperty from the response JSON. For more information on the pointer, see the note below.
CommandNode's success port to the
JSON QueryNode's trigger port, and its value port to the
JSON QueryNode's input port.
Equal ComparisonNode and configure it to use the
JSON QueryNode's main port to the
Equal ComparisonNode's trigger port, and its value port to the
ConstantNode and configure it to the
Stringvalue of "ACCEPTED."
ConstantNode's value port to the
Response: SuccessNode and a
Response: Execution FailedNode to the action flow.
Equal ComparisonNode's true port to the
Response: SuccessNode's trigger port, and its false port to the
Response: Execution FailedNode's trigger port.
The following image shows the finished action flow:
The pointer defines the string syntax for identifying a specific value in a JSON object. Here's an example:
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:
As shown in the example graph, the user's utterance value is 50. The user utterance "Increase the volume of the speaker by 50" executes the SmartThings Capabilities
audioVolume command. For more information, see Sending A Device Command With an Argument.
audioVolume POST command, the server responds with JSON:
JSON Query Node selects the
status property of the
results and parses the
status property from the response JSON. Bixby then compares the
status property output by the
JSON Query Node to the string "ACCEPTED" in the
Constant Node. The
Equal Comparison Node determines that these values are equal and triggers the "SUCCESS" response.
The Node Recommendation feature enables you to get recommendations for next possible nodes, and can make it easier to create a graph.