How to Use the ‘Parse Value’ Node in Copilot Studio: Parsing JSON Within a Topic

Since the “Parse Value” node in Copilot Studio turned out to be quite useful, I decided to document its functionality.

スポンサーリンク

The “Parse Value” Node

The “Parse Value” node is used to **convert the type of values** handled within a topic.
Its primary purpose is similar to the “JSON Parse” feature in Power Automate. You can use it to specify the type for values whose structure or type is undefined (e.g., JSON strings) so they can be manipulated within the topic.

Instead of explaining with words, I’ll demonstrate through an example.

What I Want to Do

A custom connector called “PostalCode,” which I created quite some time ago:
This custom connector retrieves an address based on a postal code. I want to add its functionality to the agent:

Structure

Adding an Action

First, add the custom connector to the agent. Go to [Add an Action]:
Select the custom connector created earlier:
Review the description, inputs, and outputs, then click [Add an Action] to complete the addition:

Creating a Topic

Next, create a topic that uses the action you just added. Add a trigger phrase indicating the intent to retrieve an address based on a postal code, and use slot filling to store the postal code in a variable:
Use the stored postal code as an argument to call the action, and send the result in a message to complete the topic:
When performing a test, the address is successfully retrieved but is obviously output in JSON format.
*The garbled text is likely due to the JSON being displayed directly:

Adding the “Parse Value” Node

The “Parse Value” node comes in handy here. Add this node immediately after the custom connector action, and set the “Target for Parsing” to the response from the custom connector (specifically, the first item in `results`). ※ The `First` function is used because the API is designed to always return a single item within the array.
Set [Data Type] to [From Sample Data], and click [Get Schema from Sample JSON].
A popup will appear prompting you to enter a sample JSON. Input a sample response returned by the custom connector, and click [Confirm].
Finally, assign the parsing result to a new variable (in this case, `address`) to complete the process.
Thanks to parsing the value, you can now use the parsed result in subsequent nodes. Configure the message content to include the parsed data.
When testing the same interaction as before, the parsed result is successfully sent as a message.

When using actions within a topic to exchange data, you will often need to handle JSON. In such cases, the “Parse Value” node is invaluable.

コメント

Copied title and URL