@Vaibhavi Shah - Thank you for bringing this issue to our attention.
To achieve your requirement of confirming user inputs for each question and saving these answers back to a SharePoint list, you can follow the steps below:
Step 1: Create an Array to Store User Inputs
You need to create an array to store the user's answers dynamically. Here’s an example of how you can do it in Copilot Studio:
// Initialize an array to store user inputs
let userAnswers = [];
// Function to add user input to the array
function addUserAnswer(question, answer) {
userAnswers.push({ question: question, answer: answer });
}
Step 2: Capture User Inputs
As you collect user inputs in your conversation, you can add these inputs to the userAnswers
array using the function defined above:
// Example function to capture user input for a qu``estion
function`` captureUserInput(question) {
``// Assume getUserInput() is a function that gets the user input
``let userInput = getUserInput(question);
addUserAnswer``(question, userInput);
}
// Call this function each time you get user input`` for a question
captureUserInput``("What is your name?");
captureUserInput``("What is your age?");
Step 3: Trigger a Flow to Save Data in SharePoint List
Once you have collected all the user inputs, you can trigger a Power Automate flow to save the data back to a SharePoint list. First, create a Power Automate flow that accepts an array of answers and saves them to the SharePoint list.
Step 4: Connect the Flow with Copilot Studio
You need to trigger this flow from your Copilot Studio actions. Here’s an example of how to do it:
Create a Power Automate Flow:
Create a new flow in Power Automate that starts with a manual trigger.
Add an action to parse the incoming data (JSON) and save each item to the SharePoint list.
Save the Flow.
**Trigger the Flow from Copilot Studio:**
Use the HTTP request action to trigger the Power Automate flow with the collected user inputs.
// Example HTTP request to trigger Power Automate ``flow
const`` flowUrl = "https://<your-flow-url>";
const`` response = await fetch(flowUrl, {
method: ``'POST',
headers: ``{
``'Content-Type': 'application/json'
``},
body: JSON.stringify``(userAnswers)
}``);
Step 5: Ensure Data is Saved to SharePoint
Make sure your Power Automate flow correctly parses the incoming data and adds each item to the SharePoint list.
By following these steps, you can collect user inputs throughout the conversation, store them in an array, and then save these inputs back to the SharePoint list using a Power Automate flow.
Doc References:
Extend with actions using Microsoft Copilot Studio - Related information
Frequently asked questions for Microsoft 365 Copilot extensibility - General questions