Creating ServiceNow Ticket from Microsoft Teams Chat Message
    • Dark
      Light
    • PDF

    Creating ServiceNow Ticket from Microsoft Teams Chat Message

    • Dark
      Light
    • PDF

    Article Summary

    We have all been there, we are busy doing something when we get a ping on Microsoft Teams and someone wants to report an issue or asks for something to be done. They start a dialog explaining what they need. After reading their message, you figure this is something that needs to be done and you don’t want to forget to do it. But who wants to go through the effort of copying and pasting the information into yet another system? There is an easier way.

    Recently, Microsoft introduced the ability to start a flow from a specific message in a Microsoft Teams chat message. The focus of this blog post is to walk through this scenario. But before we do so there are a couple pre-requisites needed:

    1. Install the Power Automate (Flow) application inside Microsoft Teams
      1-app(2)

    2. When creating the corresponding flow in Power Automate, ensure the flow is located in the Default Environment.

    With our pre-requisites out of the way we can begin to build our flow.

    1. Add the Microsoft Teams – For a selected message trigger.
      2-trigger(2)

    2. We will now create an Adaptive Card by clicking on Create Adaptive Card button.
      3-AddaptiveCard(1)

    3. Author your Adaptive Card to address your business requirements.
      4-CreateCard(2)

    4. When we log our ticket in ServiceNow, we want to be able to log it based upon the user who initiated the action. There is a field included in the Microsoft Teams message called Originating User Id that can help us. We will pass this value into the Azure Active Directory connector’s Get user action. This action will return an email address that we can subsequently look up the user in ServiceNow with.
      5-ADGetUser

    5. In order to log the ticket under the initiator’s account, we need to get their ServiceNow sys_id. We can retrieve this value by querying the ServiceNow User table using the List Records action. We can find the correct record by including a Query that will filter based upon email=Mail which is provided from our Azure Active Directory output.
      6-GetUser

    6. To avoid further loops being automatically added to our flow, we will add a Compose action to our flow and then provide an expression to retrieve the sys_id value from the first (and only) record that is returned from ServiceNow.

    Expression: first(outputs('ListRecords-_GetUserDetailsforPersonCreatedMessage')?['body/result'])?['sys_id']

    Note: the expression path that I have provided is based upon the ServiceNow action name that I have used. You will need adapt accordingly.
    7-ComposeUser

    1. We now need to perform a similar step to retrieve the Assignment Group sys_id so that we can log the ticket into the appropriate support queue in ServiceNow. This time we will query the sys_user_group (you may have to use the custom value feature). Similarly, to our scenario with users, we will use the Query feature and look for name=issueType which is the value coming from our Adaptive Card.
      8-GetGroup

    2. Once again, to avoid a loop we will add a Compose action to our flow and then retrieve the sys_id from the first (and only) record.

    Expression: first(outputs('ListRecords-_GetAssignmentGroupDetails')?['body/result'])?['sysid']

    Note: the expression path that I have provided is based upon the ServiceNow action name that I have used. You will need adapt accordingly.
    9-ComposeGroup

    1. We are now able to create our ServiceNow ticket by using the ServiceNow Create Record action and selecting the Incident - Record Type. We will then map fields as illustrated in the following image.
      10-CreateIncident

    Testing

    We can now go ahead and test on flow by starting a conversation in teams.

    1. We will start by adding a message to our team conversation. From there we can click on the … and then select More actions > Create a ServiceNo..(which is the name of our Power Automate flow)
      11-TeamsMessage

    2. Fill out the appropriate details in the Adaptive Card and click Submit.
      12-AdaptiveCard

    3. If we navigate to ServiceNow, we will discover that our incident ticket has been created.
      13-Snow

    Conclusion

    The integration of Adaptive Cards, Power Automate and Microsoft Teams provide a rich and immersive experience that allows for data to be captured in real-time without having end users needing to access other tools like ServiceNow to create a ticket. This allows them to stay within Microsoft Teams but still get data into the right system.


    Was this article helpful?