Skip to main content

Microsoft Teams Bot

Integrate a Microsoft Teams Bot with Torq to trigger workflows, manage Teams interactions, and enhance team collaboration.

Updated over a week ago

The Microsoft Teams Bot integration allows you to trigger Torq workflows and interact with Teams users, teams, channels, and messages. You can also create a bot that posts messages, tags users with the @ command, and more.

After setup, you can either mention the bot in a chat or send a direct message. In a chat, you can describe your request in free text (e.g., "check IP address") or select a command from the command list, which you'll create in this tutorial.

Torq enables quick and easy integration with the Microsoft Teams bot, so you can automate anything and everything within moments. Torq's public Teams Bot steps include:

  • Ask a Question

  • Get Channels

  • Get Users

  • Post Adaptive Card

  • +7 more...

If you don't see a step you need, you can create your own in various ways, such as using the Send an HTTP Request step or Torq’s Step Builder, and share it across your organization.

To trigger a Torq workflow based on events sent from Microsoft Teams, look here.

To use Microsoft Teams steps in Torq workflows, look here.

Prerequisites

  • The following permissions are needed, with Entra ID:

    • Application admin

    • Teams admin

    • Windows Dev Centre admin

    • Developer portal admin

    • Azure admin

  • Use the old Developer Centre interface: In the top menu bar, turn the toggle off to use the old Developer Centre.

Create a Torq bot in Teams

The Torq Teams bot is a Teams app to which you assign bot capabilities. You can use the bot to send users and channels unidirectional messages or questions that expect user responses.

You can also create one or more commands that users can execute within a chat to trigger Torq workflows. For example, if you add a command called check-ip, you can define the trigger condition only to apply when that command is used in a chat.

Create a custom apps policy in Microsoft Teams

The custom apps policy allows the user creating the bot to install custom apps for their team, including the Torq Bot. If the user already has the required permissions or a custom apps policy with the necessary permissions exists, you can skip this section and proceed directly to Create a bot in Microsoft Teams dev.

Note that you must be a Teams admin to create a custom apps policy.

  1. In Teams admin console: Log in to your Teams admin portal, navigate to Teams Apps > Setup Policies, and click Global (org-wide default).

  2. Upload custom apps: Confirm that Upload Custom Apps is set to On.

  3. New policy: If Upload Custom Apps is set to Off, create a new custom app policy.

    1. Go back to Setup Policies and click Add.

    2. Enter a meaningful name for the policy.

    3. Set the Upload Custom Apps setting to On.

    4. Click Save.

  4. Apply custom policy: Apply the custom policy to the admin-level user who will create the bot.

    1. Go to Users > Manage Users and locate the user.

    2. Hover to the left of the user's name, click the check mark icon, and click Edit settings.

    3. For App setup policy, select the policy with the Upload custom apps setting set to On.

    4. Click Apply.

Create a bot in Microsoft Teams Dev

Note that you must be a Teams admin to create a bot.

Ensure you are using the old Developer Portal by turning off the New Developer Portal toggle in the menu bar.

Create a new app

  1. Create a new app: Go to the Teams developer portal and click Apps > New app.

  2. Name app: Give the app a relevant name, such as Torq Bot, and click Create.

  3. Basic information: Within the app, go to Configure > Basic information

    1. Short Name: This is pre-filled with the name you gave your app previously.

    2. App ID: The app ID is auto-generated; copy it for later use in Torq. If you forget to copy it, you can access it again in your app Dashboard.

    3. Short description: Torq Security Automation Bot

    4. Long description: Torq’s no-code automation modernizes how security and operations teams work with easy workflow building, limitless integrations, and numerous prebuilt templates.​

    5. Developer information, company name: torq.io

    6. Developer information, website: https://torq.io/

    7. App URLs, privacy policy: https://torq.io/privacy

    8. App URLs, terms of use: https://torq.io/terms-conditions

    9. Application (Client) ID: The client ID can be found in App registrations once the Teams application is published.

    10. Click Save.

  4. Branding: Within the app, go to Configure > Branding. Branding enables you to upload custom icons for the app/bot, which will be displayed when messages are sent to users and groups. You might want to add your company's logo/icon.

    1. Upload an image for the Color icon. This is displayed in the store and most other places. The icon must be 192x192 pixels in total, with a 96x96-pixel symbol in the center.

    2. Upload an image for the Outline icon. This displays on the left side of Teams when the app is in use. The icon must be 32x32 pixels and either white or transparent.

Create a new bot

  1. Configure bot features: Go to Configure > App Features and click Bot.

    1. Click Create new bot.

    2. Click +New Bot, enter a name for the bot, and click Add.

    3. Click the new bot you made and click Configure.

    4. In the Bot endpoint address field, use the following:

      • If your organization is US-based (the URL for your Torq application portal is https://app.torq.io), enter: https://teams-app.torq.io/teams/v1/interactivity-hooks

      • If your organization is EU-based (the URL for your Torq application portal is https://app.torq.io), enter: https://teams-app.eu.torq.io/teams/v1/interactivity-hooks

    5. Click Save.

    6. Go to Client Secrets and click + New client secret. Copy the generated secret and save it in a secure location for later. Click Done

  2. Return to Bot Card: Within the app, click Configure > App features and click the Bot card.

  3. Define your Bot:

    1. Under Identify your bot, select the bot you just created from the list.

    2. Under What can your bot do?, select the desired scopes (we recommend at least Upload and download files).

    3. Under Select the scopes where people can use your bot, select all of the scopes (Personal, Team, and Group Chat).

  4. Finalize: Click Save, and then click Publish in the top right of the menu bar.

  5. Publish: Select Publish to your org, and then Publish your app.

It may take some time for your bot to be published to your Teams web app.

Grant the App Permission in the Teams Admin Portal

After publishing your app, you must have an admin approve the app in the Teams Admin portal.

  1. Navigate to Admin Portal: Go to the Teams admin portal and go to Teams apps > Manage apps.

  2. Find app: In the search box for the table, search for the Teams app name you created earlier and click to open.

  3. Publish app: On the application, click Publish.

Grant the App Permission in the Azure Portal

The permissions granted to the app determine which actions you can perform as steps in Torq workflows.

  1. Navigate to Azure portal: Go to your Azure portal and navigate to App registrations.

  2. Find your app: Click on View all applications in the directory and search for your bot by its name. Click to open.

  3. Overview: Copy the Directory (tenant) ID and save this for later.

  4. Allow accounts: Click on the entry for Supported account types.

    1. Under Supported account types > Who can use this application, select Accounts in any organizational directory/Multitenant.

  5. Enable permissions: Go to Manage > API permissions, click +Add a permission > Microsoft Graph > Application permissions and add the following permissions.

    1. AppCatalog.Read.All

    2. Group.Read.All

    3. TeamsAppInstallation.ReadWriteForTeam.All

    4. TeamsAppInstallation.ReadWriteForUser.All

    5. User.Read.All

    6. The following permissions are optional but should be added if you plan to use this Microsoft Teams Bot integration with both Microsoft Teams Bot steps and Microsoft Teams steps (Microsoft Teams steps are also compatible with the Microsoft 365 integration):

      1. Channel.ReadBasic.All

      2. Chat.ReadWrite.All

      3. Team.ReadBasic.All

      4. TeamsAppInstallation.ReadForUser.All

  6. Finalize: Click Add permissions and then Grant admin consent.

Create Bot Commands

Before you create bot commands, determine the actions you want your users to be able to perform from within a chat. In Torq, the command name will trigger a workflow.

For example, if you create a command called check-ip, each time that command is used in a chat, it will trigger a workflow that parses the IP address sent in the chat and submits it for analysis. The workflow can then return the analysis results to the same (or a different) chat.

  1. Go to Microsoft Teams dev portal: In the Teams developer portal, go to your Apps and select the app you created. Go to App features > Bot.

  2. Create a command: Click Add a command, and configure the command:

    1. Enter a name for the command. This name will be displayed in chats.

    2. Enter a description for the command that explains what the command does. This description will be displayed in chats.

    3. Select all of the scopes.

    4. Click Add.

  3. Optionally add more: Optionally, add more commands by clicking Add a command.

Create a Microsoft Teams Bot integration in Torq

  1. Navigate to Integration: Go to Build > Integrations > Steps > Microsoft Teams Bot, and click Add instance.

  2. Fill in details:

    1. Integration name: Enter a unique and meaningful name

    2. Microsoft Teams Bot Client ID: Navigate to your Azure portal and click App registrations. Click the app for your Torq bot, and under the Overview page, copy the value for the Application (client) ID.

    3. Microsoft Teams Bot Client Secret: You would have copied this value to a safe location when creating the Bot in step 1f.

    4. Microsoft Teams App ID: Navigate to your Teams developer portal. In the app you created earlier, click Basic Information. Copy the value under App ID.

    5. Microsoft Tenant ID: Navigate to aad.portal.azure.com, and under your tenant, click App Registrations. Click the app for your Torq bot and copy the value for the Directory (tenant) ID.

  3. Finalize: Click Add.


FAQs

How do I generate and use an authentication token for a Microsoft Teams Bot step?

Some Microsoft Teams Bot steps require an authentication token, while others require an integration instance. Make sure you add the Microsoft Teams Bot Generate Microsoft Teams Bot API Token step before other Teams Bot steps so you can pass the generated token in subsequent required steps.

Why am I not seeing my app in the Teams admin portal?

After you publish the Torq Teams App to your organization, it may take several hours to appear in the Teams admin portal because Microsoft needs time to propagate the application across your infrastructure.

Why am I receiving a 400 or Bot Framework error when creating a Teams bot?

To create a bot, the app must have the correct permissions. In the Azure portal, open the relevant app's Manage > Authentication tab and under Supported account types select Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant).


Templates

Now that you've added the integration check out these templates specially crafted by Torq's security experts. Visit Torq's template library for more.

Did this answer your question?