Use variables for follow-up actions

Completed

In this module, variables have been used in survey invitations to assist in creating a personalized experience for the recipient. The ability to display a name or data that is related to the feedback request is an important part of providing exceptional customer service and making customers feel valued and appreciated. You might be wondering, then, what happens to those variables after a response has been received. They are actually passed through to the response and can be retrieved and used to act on the data as required.

Consider that different types of variables can be added to a survey. As previously mentioned, variables can be used to display data. However, a variable could also be used as a hidden variable to link responses from multiple surveys together or to be used as a trigger condition to determine when a flow in Power Automate should run.

When a response is received, a flow can be triggered by using the Microsoft Dataverse connector on the Customer Voice survey responses table. You can access the Settings area on the trigger to ensure that this flow only runs for a specific survey, if required.

A screenshot of configuring a when a record is created flow step.

By using an expression similar to the one in the following example, you can update the Trigger Conditions section so that the flow only runs if the response is for a survey with a specific ID.

@equals(triggerBody()?['_msfp_surveyid_value'], 'SURVEY ID')

Settings screen for survey response. Settings include Custom Tracking ID, Secure Inputs (Preview), Secure Outputs (Preview, Retry Policy, Concurrency Control, and Trigger Conditions.

After the trigger condition is met, the flow will continue to run and go to the next step. The first action that is needed in the flow is to get the survey response details. By using the Microsoft Forms connector, you can use the Get response details action to get the details. For the response ID, the following expression is required to parse the source response identifier value from a string into an integer value.

int(triggerBody()?['msfp_sourceresponseidentifier'])

Next, you need to access the variables that have returned in the survey response. All variables that were used in the survey invitation are stored in a survey response in the Context Data column on the record in Microsoft Dataverse. For organizations with licenses for Microsoft Power Apps, a model-driven app can be created, which gives users direct access to the survey response records. The Survey Response form can be customized to clearly show the Context Data column. Users can then see the variable name, followed by the value that was passed through in the survey invitation. The following example shows that the First Name is Jane and the Last Name is Doe. The information in the Context Data area can be copied and pasted for use in the flow.

CDS record highlighting the Context Data column.

For organizations without a Power Apps license, accessing the context data is still possible through Power Automate as part of the same flow. Search for and add a Compose step directly after the Get response details step. Then, on the Dynamic content tab, search for the Context Data column from the initial trigger step and add that column into the inputs for the Compose step. This part is only needed once so that the Context Data column can be accessed and used in the next steps of the flow. If the survey is completed as a test, the flow will run and ideally will be successful. By selecting the successful run to view the flow, the Compose step should include the context data JSON file in the output.

From this point on, it shouldn't matter if an organization has a Power Apps license or not. Continue to edit the flow and add a Parse JSON step. Add the context data to the content value, and then select Generate from sample at the bottom of the action step. Paste in the context data values that were copied either from the Compose step (in the situation without access to Power Apps) or from a survey response record in a Power Apps model-driven app (with access to Power Apps).

For the rest of the flow, the variables and the related values will be accessible as dynamic content from the Parse JSON step. This feature provides excellent possibilities in terms of acting on the data. Use the values to create new records, update records, or send notifications. Values for specific questions can be verified and actions can be carried out based on an organization's requirements. Variables are important for customization of a survey and for follow-up actions based on the results that are submitted by respondents.

Configuring a flow to add a row to a table.