Alloy Navigator notifications in Microsoft Teams
Updated in 2024
Alloy Navigator notifies the stakeholders about various events using good old email and push notifications. However, you may use other channels to communicate with your colleagues, such as Microsoft Teams. This article describes how to send alerts to Microsoft Teams to keep your teammates updated about events in Alloy Navigator.
Here are the steps you should take:
Create a Power Automate workflow in Microsoft Teams
Learn how to set up a workflow in Microsoft Teams that will send alerts whenever a new incident is created in Alloy Navigator. Please note that the workflow will need a Microsoft 365 account to authenticate connections and post to the channel. The account must be a member of the host team.
To set up a custom workflow in Microsoft Teams:
-
In Microsoft Teams, go to the channel where you want alerts to appear.
TIP: You can create a new channel for this purpose.
-
In the upper-right corner next to the channel name, click the ellipsis button to reveal more options and choose Workflows.
-
Select Post to a channel when a webhook request is received from the screen listing available workflow templates.
-
Authenticate the workflow using a Microsoft 365 account, which is a member of the host team. The workflow will post alerts on behalf of that account.
-
Click Add workflow. Power Automate will create the workflow and respond with the webhook URL.
-
Click the Copy button to copy the URL to the Clipboard, and keep it save. You will need that URL later to tell Power Automate where to post information to Microsoft Teams.
-
Click Done.
The workflow is ready to receive alerts from Alloy Navigator sent via PowerShell.
Create an adaptive card using the Adaptive Cards designer
The request sent to the workflow is an adaptive card, composed of elements like text blocks, images, and fact sets. To create this adaptive card, you can use the Adaptive Cards designer app.
Here is an example of how your card could be structured:
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "[T000031](https://example.com/wp/go/T000031)",
"size": "Medium",
"wrap": true,
"weight": "Default"
},
{
"type": "TextBlock",
"text": "Unable to create a new site",
"isSubtle": true,
"spacing": "None",
"wrap": true,
"weight": "Bolder",
"size": "Medium"
},
{
"type": "TextBlock",
"text": "by Maxwell Newcomb",
"isSubtle": true,
"wrap": true,
"size": "Medium"
},
{
"type": "TextBlock",
"text": "in project M365 Rollout",
"isSubtle": true,
"spacing": "None",
"wrap": true,
"size": "Medium"
}
]
}
]
}
NOTE: Note that we are using sample values for the text in the card. Later, a PowerShell script will replace these with placeholders from the Alloy Navigator workflow to populate the texts at runtime. Although it might seem that placeholders could be used directly in the card’s JSON code, not all characters are supported by JSON. To ensure data integrity, dynamic values will be inserted into the card later using the script.
This is the preview of the example card shown above:
When your card design is complete, copy the resulting JSON from the Card Payload Editor panel in the Adaptive Cards Designer. You will need to paste this JSON into a PowerShell script in the next step.
Add a PowerShell script to the Alloy Navigator workflow
When the webhook in Microsoft Teams and the adaptive card in the designer are ready, configure the Alloy Navigator workflow to send alerts to the Teams channel when certain events in Alloy Navigator occur.
For example, you can set up posting a message when a new Incident in Alloy Navigator is submitted. To do so, create a trigger that will fire on creating Incidents and send messages to the webhook using PowerShell.
It is convenient to store your actual webhook URL from the first step as a workflow configuration parameter. This way, you can easily update it if needed, without the need to edit the trigger itself.
To create a workflow parameter for your webhook URL:
-
In Alloy Navigator Settings, go to Workflow and Business Logic > Advanced > Configuration Parameters, select or create a category (for example, Integrations > Microsoft Teams), and click New. The Workflow Parameter dialog box opens.
-
Specify a meaningful name and add a description. To follow our example, use the name New Incidents Webhook.
- In the Value field, paste the URL you copied from Teams, and save the parameter.
At this point, you may want to first create a testing Step Action that you can use to test your incidents and send notifications about them to the Teams channel configured for your Power Automate workflow. After this, you can create the trigger as described below.
IMPORTANT: For simplicity, our example below does not include error handling. If the PowerShell script fails to send a request to the specified webhook, users will just not receive a notification in Teams. If you require more advanced logic with error handling, please contact our Support Team.
To create a trigger in Alloy Navigator:
-
In Alloy Navigator Settings, go to Workflow and Business Logic > Service Desk > Incidents > Workflow > Triggers > On Created/Modified and click New.
-
Enter a trigger name and optionally a description.
-
Next to Execute when, leave the Object in created option selected.
-
Switch to the Programming tab and click New > External Command to bring up the External Command dialog box.
-
Under Run command on, click Server and then copy the following PowerShell script and paste it under Run.
# In this example, the actual URL is stored as a workflow configuration parameter in Alloy Navigator $webHook = '%[WFP New Incidents Webhook]%' # And actual values are obtained through Alloy Navigator workflow $ticket = "%[DBF Ticket]%" $title = "%[DBF Summary]%" $creator = "%[DBF Requester_ID.Full_Name]%" $project = "%[DBF Project_ID.Placement]%" $viewUrl = "%[SYS Web Portal Link]%go/%[DBF Ticket]%" # Define a protype adaptive card to use to post to the webhook $card = '{ "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.2", "body": [ { "type": "Container", "items": [ { "type": "TextBlock", "text": "[T000031](https://example.com/wp/go/T000031)", "size": "Medium", "wrap": true, "weight": "Default" }, { "type": "TextBlock", "text": "Unable to create a new site", "isSubtle": true, "spacing": "None", "wrap": true, "weight": "Bolder", "size": "Medium" }, { "type": "TextBlock", "text": "by Maxwell Newcomb", "isSubtle": true, "wrap": true, "size": "Medium" }, { "type": "TextBlock", "text": "in project M365 Rollout", "isSubtle": true, "spacing": "None", "wrap": true, "size": "Medium" } ] } ] }' $cardObject = $card | ConvertFrom-Json $cardObject.body[0].items[0].text = "[$ticket]($viewUrl)" $cardObject.body[0].items[1].text = $title $cardObject.body[0].items[2].text = "by $creator" $cardObject.body[0].items[3].text = "in project $project" $bodyObject = [PSCustomObject] @{ 'type' = 'message'; 'attachments' = @( @{ 'contentType' = 'application/vnd.microsoft.card.adaptive'; 'contentUrl' = $null; 'content' = $cardObject; } ) } $body = $bodyObject | ConvertTo-Json -Depth 100 # return $body $Result = @([PSCustomObject] @{ Code = 0; Exception = ''; }) # Post the card to the webhook Try { Invoke-RestMethod -uri $webHook -Method Post -body $body -ContentType 'application/json' } Catch { $Result = @([PSCustomObject] @{ Code = 1; Exception = $_; }) }
where:
%[WFP New Incidents Webhook]%
: The workflow parameter that stores the webhook URL from Microsoft Teams%[SYS Web Portal Link]%
: The Web Portal Link system macro that inserts the Alloy Navigator Web App URL. For details, see Installation Guide: Customizing the Web Portal Link Macro%[DBF Ticket]%
: The placeholder for the Incident number%[DBF Summary]%
: The placeholder for the Incident summary%[DBF Requester_ID.Full_Name]%
: The placeholder for the Incident's requester name-
%[DBF Project_ID.Placement]%
: The placeholder for the Incident's project
TIP: If you want to send alerts only about high-priority Incidents, or you have other criteria in mind, switch to the Condition tab and create a trigger condition. For details, see Administration Guide: Building Criteria.
-
Click OK to close the External Command dialog box, and then click OK to save the trigger.
Everything is ready!
Now Alloy Navigator will automatically post a new message to your Microsoft Teams channel whenever a new incident is submitted. Clicking the Incident number will open that incident in the Web App.