Get Microsoft Forms responses submitted today

Using Power Automate to retrieve Microsoft Forms responses is a pretty common use case. In this setup I am showing you how you can retrieve responses which have been submitted today.

Inspiration

This question from MNAM:

So basically, is it possible to build a flow, that only looks at the date of the forms? So if there has been 3 forms filled out on the same day, it will only send out 1 mail, and the same if there has only been 2 filled forms it sends 1 mail etc.

Power Users Community thread: Power Automate mail based on number of reply per day.

New Hires

Like suggested in the thread we want to collect all responses which have been submitted today via a Microsoft Forms registration form. Let’s set the scene and use an example, a new hire process.

newemployeeregistration

In this process a manager can register details for a new hire. Multiple entries can be submitted in day. This will be forwarded to the IT employees so they can process the requests. They need some preparation time to configure accounts, a user device, etc. However, they don’t want to receive a notification of every single new item, they would prefer to get a notification at the end of the day with all new submitted responses of that specific day.

newemployeeregistration_mail

Forms API

There are already lots of examples on the internet for collecting responses. Hiro has shared a nice blog about Get Question details of Forms with Power Automate, Reza Dorrani has a great video about How to Get Forms Responses using Power Automate and Damien Bird has a nice video about Microsoft Forms Get ALL Response Details Downloaded via Power Automate.

Definitely check out these resources before you starting building your flows.

In my setup I am adopting Hiro his approach. I am using the same Forms API but simply using the responses method of that API.

Flow setup

responses_answers_formapi

1. Add a Recurrence trigger action.
Set the interval and frequency to 1 x Day. Make sure your start time is at the end of the day.

recurrence_oneday

2. Add a Get my profile (v2) action.

getmyprofile

3. Add a Initialize variable action.
Select type String. Call it FormId. Add your form Id as the value.

initializevariableformid

4. Add a Send an HTTP request to SharePoint action.
Make sure you use the GET method and the https://forms.office.com as a custom value for the Site Address. Use the parameters/uri from the code snippet below.
The Uri uses a tenant id, user id and form id. Update to your own values where appropriate.

sendanhttprequest_formsoffice

5. Add a Filter Array action.
Use the body values of the output of the Send an HTTP request to SharePoint action in the From field. Check if the submitDate is greater than or equal to today 00:00. Grab the expression with utcNow function from where field in the code snippet below.
Because we would schedule to run the flow at of the day you would only get today’s entries

filterarray_responsestoday

6. Add a Select action.
In the From use the Body of the Filter Array action. In the Map use the expressions select field in the code snippet below.
The item answers field is converted with a json function. After that the correct answer1 value is retrieved with an index [0] or [1]. You might need to use different index numbers dependent on the order of your questions.

select_responsesanswers

7. Add a Create HTML Table action.

createhtmltable_responses

8. Add a Compose action.
I used some CSS from Ryan Maclean again, check out his blog, Power Automate HTML table styling.

cssinjectinghtmltable

9. Add a Send an email (v2) action.
Add a values for the To and Subject fields. In the Body switch to HTML. Add your preffered HTML content and include the Outputs of the Compose action.

sentemailwithhires

That should be it for the setup.

Happy testing!

You may also like...

3 Responses

  1. Steve Morley says:

    What about deleting them using Power Automate. This video and this post show it’s possible but I’m still fighting with the syntax. https://www.youtube.com/watch?v=eq6QRz29q9Q
    https://mofumofupower.hatenablog.com/entry/formsapi

  2. Chad Kealey says:

    Is there a way to retrieve a specific response using the rest api? For example, if I want to get the time that the user started filling out the form, that data is available, but not part of the “response details”. If a form has a small number of responses, getting them all and then filtering would obviously work, but it seems inefficient to do the same if I know I only want one piece of data from on particular form response.

  3. Steven Moran says:

    Regarding your HTTP request code, it looks like you are looking to return only 3 different data fields from each response. When I attempt this, the output of that step looks no different than the same request for responses without the “select”.

    When attempting to filter the HTTP response, when using your expression pattern for the “From” I am told that the expression is invalid. Also, in the GUI view for that action, it appears that “submitDate” has somehow been recognized by PowerAutomate as data from a previous expression. That is not represented in my environment.

    Might you have any idea why I have these discrepancies?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.