- 02 Dec 2024
- 4 Minutes to read
- Print
- DarkLight
- PDF
Microsoft Teams - Send Direct Message to a Channel
- Updated on 02 Dec 2024
- 4 Minutes to read
- Print
- DarkLight
- PDF
Microsoft Teams - Send Direct Message to a Channel sends a direct message in Microsoft Teams to the designated channel for:
- Assets returned by the selected query or assets selected on the relevant asset page.
- Not all asset categories are supported for all Enforcement Actions.
- See Actions supported for Activity Logs, Adapters Fetch History, and Asset Investigation modules.
- See Actions supported for Vulnerabilities.
- See Actions supported for Software.
Required Fields
These fields must be configured to run the Enforcement Set.
- Action name - The name of this Enforcement Action. The system sets a default name. You can change the name.
- Configure Dynamic Values - Toggle on to enter a Dynamic Value statement. See Creating Enforcement Action Dynamic Value Statements to learn more about Dynamic Value statement syntax.
Use stored credentials from Microsoft Entra ID (formerly Azure Active Directory) and Microsoft Intune adapter - Select this option to use credentials from the adapter connection. By default, the first connection is selected.
- When you select this option, the Select Adapter Connection drop-down becomes available. Select the adapter connection to use for this Enforcement Action.
NOTETo use this option, you must successfully configure an Microsoft Entra ID (Azure AD) adapter connection. Each asset is run using the connection that fetched the asset.
Recipient Team ID - The Entra user ID of the user who will receive the message.
Recipient Channel ID - The ID of the channel to which the message will be sent.
Custom message - The text of the Microsoft Teams direct message.
Additional Fields
These fields are optional.
Connection and Credentials
When Use stored credentials from the adapter is toggled off, some of the connection fields below are required to create the connection, while other fields are optional.
- Azure Client ID - The Application ID of the Axonius application.
- Azure Client Secret - Specify a non-expired key generated from the new client secret.
- Azure Tenant ID - Microsoft Entra ID (Azure AD) ID.
API
Axonius uses the Azure AI Bot Service API.
Required Permissions
The following Microsoft Graph permissions are required for the action to work:
- AppCatalog.Read.All
- TeamsAppInstallation.ReadWriteForUser.All
- TeamsAppInstallation.ReadWriteForTeam.All
Required Ports
Axonius must be able to communicate with Microsoft Teams via TCP port 443.
Set Up the EC Action
To set up this EC Action, you need to first configure a new designated bot in Microsoft Teams and then create a new application in Microsoft Teams.
Configure the Bot
- Navigate to https://dev.botframework.com/bots/new and create a new bot.
- Fill the following fields:
- Display name - Any name you want for this bot.
- Bot handle - The Client ID of the Azure application.
- Messaging endpoint - Copy the "Webhook URL" from the Axonius configuration (Global settings - Workflows Events - Microsoft Teams). This is only necessary if you are using "Create list of predefined responses" configuration in the action.
- App type - The tenancy type for the Azure app.
- Paste your app ID below to continue - The Client ID of the Azure application.
- App Tenant ID - The Azure Tenant ID (if single tenancy mode is selected).
- Click Register.
Set Up the App with the Developer Portal
In Microsoft Teams, from the side panel, click Apps.
Using the search bar, search for "developer portal".
From Microsoft Corporation, click Developer Portal.
Click Add (or Open).
In Developer Portal, click Apps.
Click New app.
Enter a name for the app and click Add.
On the Basic information page, fill the following fields:
- Short description
- Long description
- Developer or company name
- Website
- Privacy policy
- Terms of use
Click Save.
Click App features.
Click Bot.
Select Select an existing bot, and choose the bot you created earlier.
Under "Select the scopes in which people can use this command", select Personal, Team, and Group Chat.
Click Save.
In Developer Portal, from the top toolbar, click Tools.
Click Bot management.
Click the bot you've created.
Click Channels.
Make sure Microsoft Teams is checked.
Click Save.
Install the New App in Teams Through the Admin Center
After you set up the app there are two potential ways for installing the app. If this process for installing the app through the Teams portal doesn't work, see the next process for installing the app using a downloaded zip file.
- In Developer Portal, from the top toolbar, click Apps.
- Select the app you created.
- On the top-right of the screen, click Publish.
- Select Publish to your org.
- Click Publish your app
- Navigate to Teams App Management.
- Search for your app and click on it.
- Click Publish.
- When prompted, confirm in the pop up.
Install the New App in Teams Through the Developer Portal
- In Developer Portal, from the top toolbar, click Apps.
- Select the app you created.
- On the top-right of the screen, click Publish.
- Select Download the app package to download a zip file containing the application.
- Navigate to Teams App Management.
- On the top right, click Actions.
- Click Upload new app.
- Click Upload.
- Choose the file you downloaded.
Get the Channel ID and Team ID
- Go to Teams
- Click More Options (…) in the specific channel.
- Click Get a link to channel.
- The Channel ID is the value after
/channel/
and before the next/
- The Team ID is the same as groupId
For example:
Go to the link:
https://teams.microsoft.com/l/channel/19%3Ade6df9ad68c4438080e31ee6181ccbc4%40thread.tacv2/IDM%20Tests%20Channel?groupId=a3d878fd-48f4-47d1-aae9-5ce72b4137c2&tenantId=d5d0rrss-195d-4675-1340-c1a4871a1118
The ID is
19%3Ade6df9ad68c4438080e31ee6181ccbc4%40thread.tacv2
Replace:
%3A
with a colon (:)Replace
%40
with @The final ID is
19:Ade6df9ad68c4438080e31ee6181ccbc4@thread.tacv2
The Team ID is the same as the groupId:
Team ID:a3d878fd-48f4-47d1-aae9-5ce72b4137c2
For more details about other Enforcement Actions available, see Action Library.