Hidden Gems - Converting the Table Response Into String Variable

In this blog, we will dive into how to leverage an undocumented component to convert the table variable into a string variable in the Copilot Studio.

Typical Scenario

When you want to process the information that is received as a response from the HTTP API call in the Power Automate Action flow or AI Prompt Builder, there is a challenge. The response obtained from the API call will be received as an object or array format, but the information to be processed is expected as a string variable.

If you want to pass to the string information, you do not have a straightforward method of converting the object or array information straightforwardly. An undocumented node is available to bypass this challenge.

Follow the step below to get the solution for converting any format to a String variable.

Open the Topic in Code Editor by clicking the More option just before the Save Topic button.

Code Editor

Go to the section/lines next to the API component and add these four lines of code.

    - kind: SetTextVariable

      id: setVariable_ItomYcm

      variable: Topic.SPresponse

      value: "{Topic.GetItems.value}"
  • kind: SetTextVariable – This is a “Set to String variable” that is not available in the UI to add.
  • id: setVariable_ItomYcm – This must be a unique identifier for the component added.
  • variable: Topic.SPresponse – Refer to the new string variable to store the responses.
  • value: "{Topic.GetItems.value}" – Refer to the response received from the HTTP API call.

HTTP API

Once the modification has been done, close the editor.

Modification

You would be able to see the new component added to your action like this.

Component added