Jump to content

Maximizing Feedback: Integrating Adaptive Cards with Microsoft Teams for ServiceNow Ticket Surveys


Recommended Posts

Guest luisdem
Posted

In any organization, gathering feedback from customers and employees is essential to improve products and services, as well as to enhance the overall experience. However, obtaining that feedback can be a challenging task, especially when you need to reach out to a large number of people.

 

 

 

Fortunately, with the rise of digital communication tools and collaborative apps, it's becoming easier than ever to gather feedback efficiently and in a timely manner. Among these apps, Microsoft Teams stands out as one of the most popular and versatile options, providing a unified platform for team communication and collaboration.

 

 

 

In this post, we'll explore how you can leverage Microsoft Teams to gather feedback from your customers or employees via surveys sent as Adaptive Cards, using ServiceNow as the source of information. Specifically, we'll discuss how to set up an automated process that sends Adaptive Cards to Microsoft Teams after a ticket is closed on ServiceNow, making it easy for respondents to provide feedback directly from Teams. By doing so, you'll not only save time and effort but also increase the response rate and improve the quality of the feedback you receive.

 

 

 

Prerequisites

 

 

Service Now Environment

 

 

 

 

ServiceNow provides a free development environment called the Now Platform (ServiceNow Developers), which enables developers to quickly build, test, and deploy applications to improve workflows and productivity within their organizations. With a free account on the Now Platform, you can start building powerful applications that leverage ServiceNow's advanced capabilities for workflow management, incident management, and service requests. Whether you're an experienced developer or just getting started, the Now Platform offers a flexible and easy-to-use environment for creating custom solutions tailored to your organization's unique needs.

 

 

Microsoft Teams

 

 

 

 


  1. Go to the Microsoft Teams website (Video Conferencing, Meetings, Calling | Microsoft Teams) and click on the "Sign up for free" button.
     
     

  2. Enter your email address and click on "Next". If you already have a Microsoft account, you can sign in with that account.
     
     

  3. Create a new password and click on "Sign up".
     
     

  4. Follow the prompts to complete the setup process, such as entering your name and company information.
     
     

  5. Once your account is set up, you can download the Microsoft Teams app on your desktop or mobile device and start collaborating with your team.
     

 

 

 

With a free Microsoft Teams account, you can chat with colleagues, make voice and video calls, share files, and collaborate on projects from anywhere. Plus, with its seamless integration with other Microsoft products, such as Office 365 and SharePoint, Microsoft Teams can help streamline your organization's workflows and improve productivity.

 

 

 

Power Automate Environment

 

 

 

 

Microsoft provides a free Power Automate environment (Power Automate | Microsoft Power Platform), which enables users to automate workflows across multiple applications and services. With Power Automate, you can create automated processes, such as approvals, notifications, and data synchronization, to save time and increase efficiency. Whether you're a business user or a developer, the Power Automate environment provides an intuitive and easy-to-use interface for creating and managing workflows. Plus, with its seamless integration with other Microsoft products, such as Teams and SharePoint, Power Automate can help streamline your organization's workflows and improve collaboration.

 

 

 

 

 

Power Automate or Logic Apps Part

 

 

 

 

To automate the process of sending Adaptive Cards to Microsoft Teams after a ServiceNow ticket is closed, you can use either Power Automate or Logic Apps. With these tools, you can create a flow that retrieves the necessary information from ServiceNow and then prepares and sends the Adaptive Card to Teams.

 

 

 

In this post, I am demonstrating how to use Power Automate to automate the process of sending Adaptive Cards to Microsoft Teams after closing a ServiceNow ticket. However, the process is similar if you decide to use Logic Apps instead, so feel free to choose the tool that best suits your needs and preferences.

 

 

 

Steps:

 

 

 


  1. Open a web browser and go to the Power Automate portal.
     
     

  2. Sign into Power Automate using your Microsoft account or organizational account.
     
     

  3. Once you're signed in, you should see the Power Automate portal dashboard. On the left-hand menu, click on "Create" to create a new flow.
     
     

  4. Choose a template from the available options or start from scratch by selecting "Instant - from blank".
     

 

 

 

largevv2px999.png.40f7374bd227923740917982af9301c4.png

 

 

 

 

 

 

 

 

 

  1. Give your flow a name, such as Closed Ticket Survey via Service Now. Choose the When an HTTP request is received as the trigger, and click on Create.

 

 

 

largevv2px999.png.cb0372348c0c685dfd991ffe017c818a.png

 

 

 

 

 

 

 

 

 

HTTP triggers are a powerful feature in Power Automate that allows us to create custom APIs and automate processes with external systems. By creating a custom HTTP trigger, we can make the approval process more flexible and scalable, and enable other systems to interact with Microsoft Teams Approvals without having to go through Service Now.

 

 

 

To set up the "When a HTTP request is received" trigger, we need to define the input parameters that will be sent via a rule from Service Now (we will create this rule later).

 

 

 

  1. Click on the "When a HTTP request is received" trigger to select it. Paste the following Request Body JSON Schema that will be sent by Service Now into the text box:

 

 

 

 

 

{

"type": "object",

"properties": {

"number": {

"type": "string"

},

"short_description": {

"type": "string"

},

"description": {

"type": "string"

},

"resolved_by_name": {

"type": "string"

},

"resolved_by_email": {

"type": "string"

},

"state": {

"type": "string"

},

"closed_at": {

"type": "string"

},

"opened_by_name": {

"type": "string"

},

"opened_by_email": {

"type": "string"

},

"closed_by_name": {

"type": "string"

},

"closed_by_email": {

"type": "string"

},

"impact": {

"type": "string"

},

"urgency": {

"type": "string"

},

"severity": {

"type": "string"

},

"priority": {

"type": "string"

},

"opened_at": {

"type": "string"

},

"resolved_at": {

"type": "string"

}

}

}

 

 

 

 

 

 

The next step is sending the adaptive card to Teams.

 

 

 

  1. Add a new action after the "When a HTTP request is received" step. In the search box, type "Teams" and select the Post adaptive card and wait for a response:

 

 

 

largevv2px999.thumb.png.6a789ed32c8125e7e3259bf95f7f2a2c.png

 

 

 


  1. Select Chat with Flow bot for the Post in type field.
     
     

  2. Copy and paste the following JSON code into the message field to create the Adaptive Card:
     

 

 

 

{

"type": "AdaptiveCard",

"body": [

{

"type": "ColumnSet",

"horizontalAlignment": "Center",

"columns": [

{

"type": "Column",

"items": [

{

"type": "TextBlock",

"text": "@{triggerBody()?['number']}",

"wrap": true,

"horizontalAlignment": "left",

"weight": "Bolder",

"size": "Large"

 

},

{

"type": "TextBlock",

"spacing": "None",

"text": "@{triggerBody()?['short_description']}",

"wrap": true,

"size": "Large",

"horizontalAlignment": "Left"

},

{

"type": "TextBlock",

"text": "@{triggerBody()?['description']}",

"wrap": true,

"spacing": "Medium",

"horizontalAlignment": "left"

}

],

"width": "stretch"

}

],

"width": 1

},

{

"type": "ColumnSet",

"horizontalAlignment": "Center",

"columns": [

{

"type": "Column",

"items": [

{

"type": "ColumnSet",

"horizontalAlignment": "Center",

"columns": [

{

"type": "Column",

"items": [

{

"type": "Image",

"url": "https://adaptivecards.io/content/LocationGreen_A.png",

"altText": "Location A"

}

],

"width": "auto"

},

{

"type": "Column",

"items": [

{

"type": "TextBlock",

"text": "**Opened at**",

"wrap": true

},

{

"type": "TextBlock",

"spacing": "None",

"text": "@{formatDateTime(triggerBody()?['opened_at'], 'yyyy-MM-dd')}",

"wrap": true,

"horizontalAlignment": "Center"

}

],

"width": "auto"

}

]

}

],

"width": 1

},

{

"type": "Column",

"spacing": "Large",

"separator": true,

"items": [

{

"type": "ColumnSet",

"horizontalAlignment": "Center",

"columns": [

{

"type": "Column",

"items": [

{

"type": "Image",

"url": "https://messagecardplayground.azurewebsites.net/assets/LocationBlue_B.png",

"altText": "Location B"

}

],

"width": "auto"

},

{

"type": "Column",

"items": [

{

"type": "TextBlock",

"text": "**Resolved at**",

"wrap": true

},

{

"type": "TextBlock",

"spacing": "None",

"text": "@{formatDateTime(triggerBody()?['resolved_at'], 'yyyy-MM-dd')}",

"wrap": true,

"horizontalAlignment": "Center"

}

],

"width": "auto"

}

]

}

],

"width": 1

},

{

"type": "Column",

"spacing": "Large",

"separator": true,

"items": [

{

"type": "ColumnSet",

"horizontalAlignment": "Center",

"columns": [

{

"type": "Column",

"items": [

{

"type": "Image",

"url": "https://messagecardplayground.azurewebsites.net/assets/LocationRed_C.png",

"altText": "Location C"

}

],

"width": "auto"

},

{

"type": "Column",

"items": [

{

"type": "TextBlock",

"text": "**Closed at**",

"wrap": true

},

{

"type": "TextBlock",

"spacing": "None",

"text": "@{formatDateTime(triggerBody()?['closed_at'], 'yyyy-MM-dd')}",

"wrap": true

}

],

"width": "auto"

}

]

}

],

"width": 1

}

],

"spacing": "Medium"

},

{

"type": "ColumnSet",

"columns": [

{

"type": "Column",

"items": [

{

"type": "ColumnSet",

"columns": [

{

"type": "Column",

"items": [

{

"type": "Image",

"horizontalAlignment": "Left",

"url": "https://messagecardplayground.azurewebsites.net/assets/clock.png",

"altText": "Calendar conflict",

"width": "15px",

"height": "15px"

}

],

"width": "auto"

},

{

"type": "Column",

"spacing": "None",

"items": [

{

"type": "TextBlock",

"text": "@{formatDateTime(triggerBody()?['opened_at'], 'HH:MM')}",

"wrap": true,

"spacing": "None",

"horizontalAlignment": "Center"

}

],

"width": "stretch"

}

]

}

],

"width": "80px",

"verticalContentAlignment": "Center"

},

{

"type": "Column",

"backgroundImage": {

"url": "https://messagecardplayground.azurewebsites.net/assets/SmallVerticalLineGray.png",

"fillMode": "RepeatVertically",

"horizontalAlignment": "Center"

},

"items": [

{

"type": "Image",

"horizontalAlignment": "Center",

"url": "https://adaptivecards.io/content/LocationGreen_A.png",

"altText": "Opened by"

}

],

"width": "auto",

"spacing": "None"

},

{

"type": "Column",

"items": [

{

"type": "TextBlock",

"text": "**@{triggerBody()?['opened_by_name']}**",

"wrap": true

},

{

"type": "ColumnSet",

"spacing": "None",

"columns": [

{

"type": "Column",

"items": [

{

"type": "TextBlock",

"text": "@{triggerBody()?['opened_by_email']}",

"wrap": true,

"spacing": "None"

}

],

"width": "stretch"

}

]

}

],

"width": 40

}

],

"separator": true,

"spacing": "Medium"

},

{

"type": "ColumnSet",

"spacing": "None",

"columns": [

{

"type": "Column",

"items": [

{

"type": "ColumnSet",

"columns": [

{

"type": "Column",

"items": [

{

"type": "Image",

"horizontalAlignment": "Left",

"url": "https://messagecardplayground.azurewebsites.net/assets/clock.png",

"altText": "Calendar conflict",

"width": "15px",

"height": "15px"

}

],

"width": "auto"

},

{

"type": "Column",

"spacing": "None",

"items": [

{

"type": "TextBlock",

"text": "@{formatDateTime(triggerBody()?['resolved_at'], 'HH:MM')}",

"wrap": true,

"spacing": "None",

"horizontalAlignment": "Center"

}

],

"width": "stretch"

}

]

}

],

"width": "80px",

"verticalContentAlignment": "Center"

},

{

"type": "Column",

"backgroundImage": {

"url": "https://messagecardplayground.azurewebsites.net/assets/SmallVerticalLineGray.png",

"fillMode": "RepeatVertically",

"horizontalAlignment": "Center"

},

"items": [

{

"type": "Image",

"horizontalAlignment": "Center",

"url": "https://messagecardplayground.azurewebsites.net/assets/LocationBlue_B.png",

"altText": "Location B: Flight"

}

],

"width": "auto",

"spacing": "None"

},

{

"type": "Column",

"items": [

{

"type": "TextBlock",

"text": "**@{triggerBody()?['resolved_by_name']}**",

"wrap": true

},

{

"type": "ColumnSet",

"spacing": "None",

"columns": [

{

"type": "Column",

"items": [

{

"type": "TextBlock",

"text": "@{triggerBody()?['resolved_by_email']}",

"wrap": true

}

],

"width": "stretch"

}

]

}

],

"width": 40

}

]

},

{

"type": "ColumnSet",

"spacing": "None",

"columns": [

{

"type": "Column",

"items": [

{

"type": "ColumnSet",

"columns": [

{

"type": "Column",

"items": [

{

"type": "Image",

"horizontalAlignment": "Left",

"url": "https://messagecardplayground.azurewebsites.net/assets/clock.png",

"altText": "Calendar conflict",

"width": "15px",

"height": "15px"

}

],

"width": "auto"

},

{

"type": "Column",

"spacing": "None",

"items": [

{

"type": "TextBlock",

"text": "@{formatDateTime(triggerBody()?['closed_at'], 'HH:MM')}",

"wrap": true,

"spacing": "None",

"horizontalAlignment": "Center"

}

],

"width": "stretch"

}

]

}

],

"width": "80px",

"verticalContentAlignment": "Center"

},

{

"type": "Column",

"backgroundImage": {

"url": "https://messagecardplayground.azurewebsites.net/assets/SmallVerticalLineGray.png",

"fillMode": "RepeatVertically",

"horizontalAlignment": "Center"

},

"items": [

{

"type": "Image",

"horizontalAlignment": "Center",

"url": "https://messagecardplayground.azurewebsites.net/assets/LocationRed_C.png",

"altText": "Location B: Flight"

}

],

"width": "auto",

"spacing": "None"

},

{

"type": "Column",

"items": [

{

"type": "TextBlock",

"text": "**@{triggerBody()?['closed_by_name']}**",

"wrap": true

},

{

"type": "ColumnSet",

"spacing": "None",

"columns": [

{

"type": "Column",

"items": [

{

"type": "TextBlock",

"text": "@{triggerBody()?['closed_by_email']}",

"wrap": true

}

],

"width": "stretch"

}

]

}

],

"width": 40

}

]

},

{

"type": "TextBlock",

"text": "Rate your experience!",

"weight": "Bolder",

"color": "Accent",

"size": "Medium",

"spacing": "Medium"

},

{

"type": "TextBlock",

"text": "Please rate your experience! Your feedback is very appreciated and will help improve your experience in the future. ",

"wrap": true

},

{

"type": "Input.Text",

"placeholder": "Add a comment",

"isMultiline": true,

"id": "comment"

},

{

"type": "ColumnSet",

"columns": [

{

"type": "Column",

"width": "stretch",

"items": [

{

"type": "Image",

"altText": "",

"url": "https://i.pinimg.com/originals/6e/a7/d4/6ea7d4c1df11567ab0718192325bf6a5.png",

"selectAction": {

"type": "Action.Submit",

"data": {

"rating": "awful"

},

"title": "awful",

"id": "1"

}

}

]

},

{

"type": "Column",

"width": "stretch",

"items": [

{

"type": "Image",

"altText": "",

"url": "https://i.pinimg.com/originals/6e/a7/d4/6ea7d4c1df11567ab0718192325bf6a5.png",

"selectAction": {

"type": "Action.Submit",

"data": {

"rating": "bad"

},

"title": "bad",

"id": "2"

}

}

]

},

{

"type": "Column",

"width": "stretch",

"items": [

{

"type": "Image",

"altText": "",

"url": "https://i.pinimg.com/originals/6e/a7/d4/6ea7d4c1df11567ab0718192325bf6a5.png",

"selectAction": {

"type": "Action.Submit",

"data": {

"rating": "ok"

},

"title": "ok",

"id": "3"

}

}

]

},

{

"type": "Column",

"width": "stretch",

"items": [

{

"type": "Image",

"altText": "",

"url": "https://i.pinimg.com/originals/6e/a7/d4/6ea7d4c1df11567ab0718192325bf6a5.png",

"selectAction": {

"type": "Action.Submit",

"data": {

"rating": "good"

},

"title": "good",

"id": "4"

}

}

]

},

{

"type": "Column",

"width": "stretch",

"items": [

{

"type": "Image",

"altText": "",

"url": "https://i.pinimg.com/originals/6e/a7/d4/6ea7d4c1df11567ab0718192325bf6a5.png",

"selectAction": {

"type": "Action.Submit",

"data": {

"rating": "terrific"

},

"title": "terrific",

"id": "5"

}

}

]

}

]

}

 

],

"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",

"version": "1.4",

"msTeams": {

"width": "full"

}

 

}

 

 

 

The above Adaptive Card was generated using the Adaptive Cards Designer tool (Designer | Adaptive Cards), which allows you to create visually appealing and functional cards without the need for coding. The card was designed using the following sample data JSON.

 

 

 

{

"number": "INC0000060",

"short_description": "Unable to connect to email",

"description": "I am unable to connect to the email server. It appears to be down.",

"resolved_by_name": "user 1",

"resolved_by_email": "user@sample.com",

"state": "",

"closed_at": "2016-12-14 02:46:44",

"opened_by_name": "user 2",

"opened_by_email": "user2@sample.com",

"impact": "",

"urgency": "",

"severity": "",

"priority": "",

"close_code": "",

"opened_at": "2016-12-12 15:19:57",

"resolved_at":"2016-12-13 21:43:14",

"subcategory": "",

"closed_by_name": "user 3",

"closed_by_email": "user3@sample.com"

 

}

 

  1. Click on the Recipient text field, and add the dynamic value opened_by_email. This value will be replaced with the email address of the person who opened the ServiceNow ticket, allowing you to send the Adaptive Card directly to them in Microsoft Teams.

 

 

 

 

 

largevv2px999.png.227b2f529476e46e08673e0e9f4081d5.png

 

 

 

 

 

  1. Add a new action after the "Post adaptive card and wait for a response" step. In the search box, type "Data Operation" and select the Parse JSON:

 

largevv2px999.thumb.png.630abf9e6c81294dfd947cf668d18028.png

 

 

 

  1. Next, click on the Content text field and enter the expression body('Post adaptive card and wait for a response'). This expression will allow the flow to retrieve the JSON payload generated by the Adaptive Card and send it as the content of the message to Microsoft Teams. Finally, click on the Save button to save your changes.

 

 

 

largevv2px999.png.ed7778f9b94f90167ae17cc7110a6255.png

 

 

 

 

 

  1. Copy and paste the following JSON code into the Schema field to get the response of the survey:

 

 

 

{

"type": "object",

"properties": {

"responseTime": {

"type": "string"

},

"responder": {

"type": "object",

"properties": {

"objectId": {

"type": "string"

},

"tenantId": {

"type": "string"

},

"email": {

"type": "string"

},

"userPrincipalName": {

"type": "string"

},

"displayName": {

"type": "string"

}

}

},

"submitActionId": {

"type": "string"

},

"messageId": {

"type": "string"

},

"messageLink": {

"type": "string"

},

"data": {

"type": "object",

"properties": {

"comment": {

"type": "string"

},

"rating": {

"type": "string"

},

"id": {

"type": "integer"

}

}

}

}

}

 

 

 

 

 

largevv2px999.png.115549512c63207d6dbdfeb0f92e9fc1.png

 

 

 

 

 

Next, you'll want to save the survey results returned from Microsoft Teams in a SharePoint List for further analysis and processing. To do so, follow the steps outlined below.

 

 

 

 

 

  1. After completing the "Parse JSON" step, you'll need to add a new action to create a new item in your SharePoint List. To do so, follow the steps below:

 

 

 

  1. Click on the "Add an action" button.


  1. In the search box, type "SharePoint" and select the Create item action.
     
     

  2. Select the appropriate SharePoint Site, List, and Folder where you want to create the new item.
     

 

 

 

 

 

largevv2px999.thumb.png.d370ccf27652e72d1572194e90788435.png

 

 

 

  1. Fill in the fields for each column in your SharePoint List, using the dynamic values generated by the Adaptive Card survey response. This will allow you to capture and store the survey responses in your SharePoint List for further analysis and reporting.

 

 

 

  1. Save the flow.

 

 

 

Note that when you save your trigger, you will be given a URL that you can use to invoke the trigger from external systems.

 

Set up Service Now Business Rule

 

 

 

 

Business Rules are server-side logic that execute when database records are queried, updated, inserted, or deleted. For more details, please check the Service Now Business Rules documentation.

 

 

 

To configure a ServiceNow Business Rule that triggers a request to Microsoft Power Automate when an incident is closed, follow the steps outlined below:

 

 

 

  1. Navigate to the Business Rules module in ServiceNow. This can be done by typing "Business Rules" in the navigation bar and selecting the appropriate option.

 

 

 

largevv2px999.png.a1ed94d691ef52ebeb8e2048171dd14f.png

 

 

 

 

 

  1. Click the "New" button to create a new business rule:

 

 

 

largevv2px999.png.4d44a8aeb450ff35141747d6383b9682.png

 

 

 


  1. Give the business rule a name and description that accurately describes its purpose. For example, Incident Closed Survey.
     
     

  2. Choose the table to which the business rule applies. This can be done by selecting the table from the drop-down menu in the "Applies to" field. For example, Incident [incident].
     
     

  3. Specify the conditions that must be met for the business rule to run. This is done by adding conditions to the "When to run" section of the business rule. For example, you could specify that the rule should run after a new record is created or updated.
     
     

  4. Add a filter condition to consider only closed tickets (state is closed).
     

 

 

 

largevv2px999.png.33bb9437558986c5f1398cb860c84c03.png

 

 

 

 

 

  1. Click on the Advanced tab to define the actions that the business rule should take when it runs. This is done by adding script to the "Script" section of the business rule. The script can be written in JavaScript and can perform a variety of actions, such as updating a field, sending an email notification, or creating a related record.

 

 

 

It's important to note that creating a business rule in ServiceNow requires some knowledge of JavaScript and the ServiceNow platform. If you're not familiar with these concepts, it may be helpful to seek assistance from a ServiceNow administrator or developer.

 

 

 

Add the following code:

 

 

 

 

 

(function executeRule(current, previous /*null when async*/) {

 

gs.info("Incident Survey rule is running");

 

var snowURL = "ServiceNow";

 

var number = current.getValue("number");

var shortDescription = current.getValue("short_description");

var description = current.getValue("description");

var stateId = current.getValue("state");

 

var openedAt = current.getValue("opened_at");

var resolvedAt = current.getValue("resolved_at");

 

var closedAt = current.getValue("closed_at");

 

var impactId = current.getValue("impact");

var urgencyId = current.getValue("urgency");

var severityId = current.getValue("severity");

var priorityId = current.getValue("priority");

 

var statusDescription;

 

var openedById = current.getValue("caller_id");

var openedByName;

var openedByEmail;

 

var resolvedById = current.getValue("resolved_by");

var resolvedByName;

var resolvedByEmail;

 

var closedById = current.getValue("closed_by");

var closedByName;

var closedByEmail;

 

//this isnt the best practice. Consider change it to oauth2 authentication

var user = 'admin';

var password = 'CHANGE HERE';

 

//GET THE NAME OF WHO RESOLVED THE CASE

var resolvedByRequest = new sn_ws.RESTMessageV2();

 

resolvedByRequest.setBasicAuth(user,password);

resolvedByRequest.setRequestHeader("Accept","application/json");

resolvedByRequest.setRequestHeader('Content-Type','application/json');

 

resolvedByRequest.setEndpoint(snowURL + "api/now/table/sys_user?sysparm_query=sys_idIN"+ resolvedById +"&sysparm_fields=sys_id,name,email");

 

resolvedByRequest.setHttpMethod("GET");

 

var resolvedByResponse = resolvedByRequest.execute();

 

var resolvedByBody = resolvedByResponse.getBody();

 

var resolvedByJson = new JSONParser().parse(resolvedByBody);

 

resolvedByName = resolvedByJson.result[0].name;

resolvedByEmail = resolvedByJson.result[0].email;

 

 

gs.info("Incident Survey: name: " + resolvedByName + ", email: " + resolvedByEmail);

 

//GET THE NAME OF WHO OPENED THE CASE

var openedByRequest = new sn_ws.RESTMessageV2();

 

openedByRequest.setBasicAuth(user,password);

openedByRequest.setRequestHeader("Accept","application/json");

openedByRequest.setRequestHeader('Content-Type','application/json');

 

openedByRequest.setEndpoint(snowURL + "api/now/table/sys_user?sysparm_query=sys_idIN"+ openedById +"&sysparm_fields=sys_id,name,email");

 

openedByRequest.setHttpMethod("GET");

 

var openedByResponse = openedByRequest.execute();

 

var openedByBody = openedByResponse.getBody();

 

var openedByJson = new JSONParser().parse(openedByBody);

 

openedByName = openedByJson.result[0].name;

openedByEmail = openedByJson.result[0].email;

 

 

//GET THE NAME OF WHO CLOSED THE CASE

var closedByRequest = new sn_ws.RESTMessageV2();

 

closedByRequest.setBasicAuth(user,password);

closedByRequest.setRequestHeader("Accept","application/json");

closedByRequest.setRequestHeader('Content-Type','application/json');

 

closedByRequest.setEndpoint(snowURL + "api/now/table/sys_user?sysparm_query=sys_idIN"+ closedById +"&sysparm_fields=sys_id,name,email");

 

closedByRequest.setHttpMethod("GET");

 

var closedByResponse = closedByRequest.execute();

 

var closedByBody = closedByResponse.getBody();

 

var closedByJson = new JSONParser().parse(closedByBody);

 

closedByName = closedByJson.result[0].name;

closedByEmail = closedByJson.result[0].email;

 

//CALL POWER AUTOMATE TO SEND TO TEAMS APPROVALS

try {

 

var body = {

"number": number,

"short_description": shortDescription,

"description": description,

"resolved_by_name": resolvedByName,

"resolved_by_email": resolvedByEmail,

"state": stateId,

"closed_at": closedAt,

"opened_by_name": openedByName,

"opened_by_email": openedByEmail,

"closed_by_name": openedByName,

"closed_by_email": openedByEmail,

"impact": impactId,

"urgency": urgencyId,

"severity": severityId,

"priority": priorityId,

"opened_at": openedAt,

"resolved_at": resolvedAt

};

 

var r = new sn_ws.RESTMessageV2();

 

// Change the following URL by the one you have created as HTTP trigger on Power Automate

r.setEndpoint("https://prod-96.westus.logic.azure.com:443/workflows/ee1cfb87958044f5affdeab515873494/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=xndVM5q0vLUdIK0GG6mrPb1-_5pjaqfE2oKj0RHHtJI");

 

r.setHttpMethod("POST");

r.setRequestBody(JSON.stringify(body));

 

r.setRequestHeader("Accept","application/json");

r.setRequestHeader('Content-Type','application/json');

 

var response = r.execute();

var httpStatus = response.getStatusCode();

 

} catch (ex) {

var message = ex.message;

gs.error("Error message: " + message);

}

 

gs.info("Webhook target HTTP status response: " + httpStatus);

 

 

})(current, previous);

 

 

  1. Click on Submit to save it.

 

 

 

largevv2px999.thumb.png.9603d50b495b49d791ff59a1aac7995e.png

 

 

 

 

 

The next step is to close an incident and verify if the notification is sent to Power Automate, and subsequently to Teams. This will allow you to ensure that the integration is working correctly and that the survey feedback process is functioning as expected.

 

 

 

  1. To access the list of open incidents in ServiceNow, follow the steps below:

 

 

 

  1. Click on "Service Desk" in the ServiceNow menu.

  1. Select "Incidents" from the drop-down menu.

 

 

 

 

 

largevv2px999.png.af06ce96a520fb2d6e06928064deb079.png

 

 

 

 

 

  1. This will take you to the list of currently open incidents. Here, you can view the details of each incident and take appropriate action as needed.

 

 

 

largevv2px999.thumb.png.c9d96e68842f3a14bf1520fca7ba0b09.png

 

 

 

  1. Close an incident:

 

 

 

largevv2px999.png.677315c5d07f97856fe46b0686e55ea8.png

 

 

 

 

 

  1. Switch back to Microsoft Teams and observe that your the survey was sent:

 

 

 

 

 

largevv2px999.png.39a8388609c8d6dda293da3028154947.png

 

 

 

 

 

 

 

  1. Once the user has responded to the survey, the flow will return to Power Automate, which will then save the survey results to the designated SharePoint List.

 

 

 

 

 

largevv2px999.png.5931b01ae14eb2ffa6e42dd0218321c5.png

 

 

 

 

 

 

 

This allows you to easily collect and analyze feedback from your users, and track any changes or trends over time.

 

 

 

Conclusion

 

 

 

 

In this post, we've explored how to use Microsoft Teams and ServiceNow to collect and analyze user feedback using Adaptive Cards and SharePoint Lists. By integrating these tools, you can streamline the feedback process, improve collaboration across teams, and gain valuable insights into the needs and preferences of your users.

 

 

 

We've covered the steps involved in setting up the integration, from creating the Adaptive Card survey to configuring the Power Automate flow and SharePoint List. By following these steps, you can easily implement the feedback process in your organization and start collecting valuable insights from your users.

 

 

 

We hope you found this post useful and informative. If you have any feedback or suggestions on how to improve this integration, please share them in the comments below. We look forward to hearing from you!

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...