Posting a message to an MS Teams channel
Last updated
Last updated
This documentation references external sources.
Nexthink does not control the accuracy of third-party documentation or external updates that can result in inconsistencies.
Report any errors or inconsistencies to Nexthink Support.
This document demonstrates how to post a message to an MS Teams channel using a webhook.
After creating a new MS Teams channel, configure a new workflow using Microsoft Power Automate.
Click three dots on the created channel and select Workflows.
From the pop-up, search for and choose Post to a channel when a webhook request is received option. See the image below.
Name the workflow and define the workflow connection.
Define the Team channel (from MS Teams) to notify using the Nexthink webhook.
Select the Add Workflow button to create the new workflow.
Copy the URL for future reference for future reference. That is, for the connector credential and webhook configuration in the Nexthink web interface. See the image below.
URL example: https://xxxxx.your-instance.logic.azure.com:443/workflows/XXXXXXXXXXXXX/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=yhejWbe6e03M9-cvU-hXXXXXXXXXXXXX
Select Manage your Workflow:
Ensure the output format is set to attachments
Ensure the Adaptive card is defined as content.
For private Team channels, use the dropdowns to set Post as: User. Otherwise, you can select Fow Bot.
You must decode the URL from the Power Automator before pasting it in the webhook configuration in Nexthink.
Jump to the In Nexthink section if you do not require authentication OAuth 2.0 for the connector credentials.
Follow the steps below in Microsoft Entra ID:
Go to your Entra ID instance and register a new Application.
Manage > App registrations > New registration
Name the application and define the supported account type.
Register the application and copy the application ID for future reference when configuring the connector credentials with authetication in Nexthink.
Click on the new Client secret and define the experience date.
Copy the secret value (not the ID) for future reference when configuring the connector credentials with authetication in Nexthink.
You can only copy the secret value after created.
Navigate to the API permission tab and add the Access Microsoft Flow as signed in user permission.
Navigate back to overview of the just registered app and navigate to the to Endpoints tab.
Save the OAuth 2.0 token endpoint (v2) for future reference when configuring the webhook in Nexthink.
From the Nexthink web interface:
Configure a connector credential for the outgoing webhook to MS Team
From the connector credential configuration page, fill out the fields using the information from the configured incoming webhook in MS Teams:
Choose the HTTPS option from the Protocol drop-down.
Paste the root https://xxxxx.your-instance.logic.azure.com:443
into the URL address field from URL from MS Teams.
Choose No Auth (None) option from the Authorization drop-down.
Save the credential.
From the connector credential configuration page, fill out the fields using the information from the configured incoming webhook in MS Teams:
Choose the HTTPS option from the Protocol drop-down.
Paste the root https://xxxxx.your-instance.logic.azure.com:443
into the URL address field from URL from MS Teams.
Choose OAuth 2.0 - Client Credentials option from the Authorization drop-down.
Enter the Access token URL, Client ID and Client secret using the values from the Entra ID application registration.
Save the credential.
From the webhook configuration page, fill out the fields using the information from the connection you created in MS Teams and the connector credential defined in Nexthink:
Fill in the NQL Condition following the Configuring webhook NQL conditions documentation. See query below.
After filling in the NQL Condition, the system lists the allowed placeholders for the Payload.
Choose the configured connector credential for MS Team (depending on the case, with authentication or without authentication) from the Credentials drop-down.
Select the POST from the Method drop-down.
Paste into the Resources field, the URL endpoint from the MS Teams configuration without the root URL address. For example: /workflows/XXXXXXXXXXXXXXXXXXX/triggers/manual/paths/invoke?api-version=?????&sp=/triggers/manual/run&sv=1.0&sig=XXXXXXXXXXXXXXX
Make sure the URL is not encoded.
Add the message you want to send in Payload. See the example below.
Notice that the payload example below uses Special placeholders for alerts data model variables.
Refer to the Post an actionable message card to an Office 365 documentation from Microsoft for more information about actionable messages via connectors.
Send Test to make sure the message is pushed into MS Teams.