activities
latest
false
UiPath logo, featuring letters U and I in white

Integration Service Activities

Last updated Oct 9, 2025

Execute the thread

Description

This activity enables automated processes orchestrated by Maestro to connect to an Azure AI Foundry project and invoke agents defined inside it.

Creating the Microsoft Azure AI Foundry agent

Within Azure Foundry AI, agents can be created using coded and no-code methods as supported by Azure. UiPath connector compatibility depends on the agent being deployed and available by API at projectname/services.ai.azure.com/api/.

A strategy for Maestro to agent interaction should persist throughout agent creation. In the Maestro business process, Maestro will send a pre-defined set of parameters to the agent with a clear expectation of which parameters the agent will use in its reply back to continue driving the process to its goal.

How to use the activity

To use this activity in a Maestro agentic process, follow these steps:

  1. Add a service task element to the canvas and open the task's Properties panel.
  2. Name the service task Foundry Hello World.
  3. In the Implementation section, from the Action dropdown list, select Start and wait for external agent.
  4. Select the Microsoft Azure AI Foundry connector.
  5. Select an existing connection or create a new one. For more information, see Microsoft Azure AI Foundry authentication.
  6. From Activity, select Execute the thread.

  7. From Agent Name, select an agent previously created in Microsoft Azure AI Foundry.
  8. In Message, enter "What can you do?". Make sure to include the quotes in the prompt.

    docs image
  9. Connect the start event to the service task, and the service task to an end event node in the canvas.

  10. Select Debug to run this process. After a successful run, review the global variables and look for the {:} response from the source: Foundry Hello World. Take note of the structure of the reply.

    Note: Foundry agent execution may take up to 90 seconds to complete. In some rare situations, it can take up to 10 minutes due to the Foundry agent’s asynchronous response mechanism.

    For example, this is the agent's response to the prompt "What can you do?":

    {
      "content_value": "Here’s how I can assist you:\n\n- **Recommend AI Tools**: Suggest the best AI tools (apps, platforms, APIs) for your specific challenge, need, or workflow.\n- **Usage Guidance**: Provide clear steps on how to use the suggested AI tool for your scenario.\n- **Prompt Writing**: If the suggestion involves an AI language model (like ChatGPT, Claude, etc.), I provide you with a ready-to-use prompt tailored to your need.\n- **Comparison**: Offer quick comparisons between similar AI tools if needed.\n- **Special Cases**: Point you to tools with image/audio/video capabilities for media-related requirements.\n\n**Try me:**  \n- State your problem, task, or goal (e.g., “I need to summarize research articles”).\n- I’ll reply with the best matching AI tool and exact usage instructions/prompt.",
      "thread_id": "thread_AJhKo6PvrzCFu1dtpXV1ZEqM",
      "assistant_id": "asst_lozoOWbsiggHu9QItxfrXZt1",
      "role": "assistant",
      "run_id": "run_GS5b1gEgXElhudrhFSAtFzQo",
      "content_type": "text",
      "latest_message_id": "msg_D5MUkFj4AvsHKNdHNFQBJpAv",
      "created_at": 1758581230,
      "object": "thread.message",
      "timestamp": "2025-09-22T22:47:10Z",
      "eventType": "TRIGGER_CREATED"
    }{
      "content_value": "Here’s how I can assist you:\n\n- **Recommend AI Tools**: Suggest the best AI tools (apps, platforms, APIs) for your specific challenge, need, or workflow.\n- **Usage Guidance**: Provide clear steps on how to use the suggested AI tool for your scenario.\n- **Prompt Writing**: If the suggestion involves an AI language model (like ChatGPT, Claude, etc.), I provide you with a ready-to-use prompt tailored to your need.\n- **Comparison**: Offer quick comparisons between similar AI tools if needed.\n- **Special Cases**: Point you to tools with image/audio/video capabilities for media-related requirements.\n\n**Try me:**  \n- State your problem, task, or goal (e.g., “I need to summarize research articles”).\n- I’ll reply with the best matching AI tool and exact usage instructions/prompt.",
      "thread_id": "thread_AJhKo6PvrzCFu1dtpXV1ZEqM",
      "assistant_id": "asst_lozoOWbsiggHu9QItxfrXZt1",
      "role": "assistant",
      "run_id": "run_GS5b1gEgXElhudrhFSAtFzQo",
      "content_type": "text",
      "latest_message_id": "msg_D5MUkFj4AvsHKNdHNFQBJpAv",
      "created_at": 1758581230,
      "object": "thread.message",
      "timestamp": "2025-09-22T22:47:10Z",
      "eventType": "TRIGGER_CREATED"
    }

The agent’s output must be assigned to a process variable so it can influence the progress of the Maestro process, for example to make a decision based on a boolean evaluation, or to use the answer from a classification task.

  1. In Design mode, select the agent from the design canvas.

  2. Select Properties.

  3. Under Output, select Add new and add a variable of type String named agent_reponse.

  4. For Value, select Foundry Hello World > Response > Content value (string).

Tip: In practice, specify the structured output of your choice from the agent, and then evaluate the output within Maestro using the Expression editor to extract the specific part of the output you need in the type necessary for your process flow.

Example of handling agent output in Maestro using the Expression editor:

If the prompt was:

"What is the capital of France?" answer in a JSON only on the form of {"capital":"Normandy") only JSON output
The response is result.reponse.content_value (type string):
{"capital":"Paris"}
If we want to convert it to JSON, create a new variable of type JSON, for example answer_in_JSON and use the Expression editor:
js:JSON.parse(result.response.messages[0].content)
The result of the js expression is (type JSON):
{
  "capital": "Paris"
}{
  "capital": "Paris"
}

Troubleshooting and Tuning

Beyond establishing connectivity, you should test prompts both in the Microsoft Azure AI Foundry workspace as well as from Maestro. This ensures you achieve the desired output that can best be consumed by Maestro, assigned to variables, and passed on to other actors in the process.

We recommend that detailed prompts remain within the system prompts of the agent within Microsoft Azure AI Foundry. The user prompt which is provided by Maestro to the agent at runtime should be brief and to the point. Its role is primarily to indicate the relevant variables needed by the agent to perform a specific tasks and generate an expected consistent output.

Output that is aimed at humans, for example the reasons for an escalation, can be easily passed as natural text for the human. Output that is expected for an API/robot action must be strictly composed. Here is an example user prompt that yields a specific output from an agent. Use the C# Expression editor within Studio to add variables as needed.
"What is the quantity on inventory of Order ID " + vars.orderId_1 + "respond only with a JSON object with the quantity in the key Order_Quantity. No explanations, only JSON""What is the quantity on inventory of Order ID " + vars.orderId_1 + "respond only with a JSON object with the quantity in the key Order_Quantity. No explanations, only JSON"

The agent will reply with:

{"Order_Quantity":"100"}{"Order_Quantity":"100"}
Pay special attention to types in your request to the agent and in the actual response. Even if the response looks like type JSON, it may actually be of type string.

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo
Trust and Security
© 2005-2025 UiPath. All rights reserved.