Skip to content

Latest commit

 

History

History
19 lines (17 loc) · 6.7 KB

File metadata and controls

19 lines (17 loc) · 6.7 KB

Copilot Studio Agent Flow Setup Guide

Setup Steps

Step Description Screenshot
1 Open your Copilot Studio Environment. step-0
2 Click on the Flows tab (left sidebar). step-1
3 Click on New agent flow. step-2
4 Add the When an agent calls the flow trigger. Add an input for User Query as text. step-3
5 Click on the Plus symbol under the When an agent calls the flow action. Search and add Initialize Variable actions for:
- Space-ID (String): User needs to fill the Space ID of the Databricks Genie
- Token (String): User needs to fill the PAT Token of Databricks
- Text Output (String): Stores text output from Databricks Genie - initial value to be left empty
- Inline Data (Object): Stores query results for visualization - initial value to be left empty
step-4
6 Add an HTTP action from the HTTP subsection to send a POST request to the Databricks Genie API to start the conversation:
- URL: <Your Databricks endpoint>/api/2.0/genie/spaces/<Space-ID>/start-conversation
- Header: Authorization: Bearer <Token variable>
- Body: JSON with content: User Query
step-5.1
step-5.2
step-5.3step-5.4
7 Add an HTTP action to send a GET request to Databricks Genie API to get the status of the conversation message (use conversation_id and message_id from previous step):
- conversation_id: body('HTTP action created in Step 6')?['conversation_id']
- message_id: body('HTTP action created in Step 6')?['message_id']
- URL: <Your Databricks endpoint>/api/2.0/genie/spaces/<Space-ID>/conversations/<conversation_id>/messages/<message_id>
- Header: Authorization: Bearer <Token variable>
step-6.1
step-6.2
8 Add Initialize Variable action to store the status of the conversation message. step-7
9 Add an HTTP action to send a GET request to Databricks Genie API to get the status of the conversation message every 5 seconds until the status is COMPLETED:
   1. Add a Do until action to check the status.
   2. Before the Do until action (inside the Do section), click on the Plus symbol and add a Delay action (not Delay until action) to keep a delay of 5 seconds between the pings.
   3. Add an HTTP action from the HTTP subsection to send the get request from the Genie Conversation API using the following details:
      - conversation_id: body('HTTP action created in Step 6')?['conversation_id']
      - message_id: body('HTTP action created in Step 6')?['message_id']
      - URL: <Your Databricks endpoint>/api/2.0/genie/spaces/<Space-ID>/conversations/<conversation_id>/messages/<message_id>
      - Header: Authorization: Bearer <Token variable>
   4. Add a Set Variable action to update the Status variable with the current value of HTTP action.
   5. Update the until part with Status is equal to COMPLETED. Add the Timeout as PT5M.
step-8.1
step-8.2step-8.3
step-8.4
10 Add an HTTP action to send a GET request to Databricks Genie API to get the message content:
   - conversation_id: body('HTTP action created in Step 6')?['conversation_id']
   - message_id: body('HTTP action created in Step 6')?['message_id']
   - URL: <Your Databricks endpoint>/api/2.0/genie/spaces/<Space-ID>/conversations/<conversation_id>/messages/<message_id>
   - Header: Authorization: Bearer <Token variable>
step-9
11 We get 2 types of message content from the Genie API: text and query. For simplicity, we are focusing only on the text part and will be just passing the query as is to the user.
   1. Add an Apply to each action to iterate over the message contents fetched from the Databricks Genie API.
      - attachments: body('HTTP action created in Step 10')?['attachments']
   2. Add a Compose action for storing the result of the conditional statement as mentioned in the screenshot.
   3. Add a Switch action that checks the output of the previous Compose action. Click on the Plus symbol to add cases.
      - If the message content type is text, store it in the Text Output variable by adding an Append variable action.
      - If the message content type is query, store it in the Inline Data variable by adding a Set variable action.
step-10.1
step-10.2
step-10.3
step-10.4
step-10.5
12 Add a Respond to the agent action to respond with a structured JSON output to the Agent containing User Query, Text Output, and Inline Data. step-11
13 Click on Save draft and then Publish. step-12