Skip to main content

How-to automate Microsoft Teams

Getting required credentials

Firstly, your robot version must be v22.11.0 or later and you will need a registered app. If you don't have a registered app, please follow this guide.

  1. Sign in to the Azure portal.

  2. From your registered application's overview page, copy the Application (client) ID.

Endpoints

  1. Click Endpoints and copy your OAuth 2.0 authorization endpoint (v2) as auth_uri and OAuth 2.0 token endpoint (v2) as token_uri.

Endpoints

  1. In the left-hand navigation panel, click Certificates & secrets then click New client secret.

Certificates & secrets

  1. Enter a description for your secret and choose expiration then click Add.

Add Client Secret

  1. Copy the value of it, this will be your client secret.

Client Secret Value

How to Perform Channel Operations

First of all, to use Microsoft Teams package in your flow, it should be installed. If it is your first time and you don't have access and refresh tokens for your application then you need to use Oauth2 package for authorization. For more information about installing packages please see here.

  1. Oauth2
  • Create a new project from Flow Designer

  • Follow the vault guide and create a new vault if you did not create a vault before.

  • Open your vault ( in this example the previously created vault's name is Sample Vault ).

Sample Vault

  • Click "Create Item" and then "Document Item".

Create Vault Item

  • Give a name to your Vault Item.

Vault Item Naming

  • Document item has Filename and Content sections give a name to this file and set a json for content as shown with your credentials.
note

{ "client_id": "your_client_id", "client_secret": "your client_secret", "auth_uri": "your_auth_uri", "token_uri": "your_token_uri" "scopes": [ "offline_access", "https://graph.microsoft.com/.default" ] }

  • After clicking save, you will see the new vault item in your Vault.

Document Item

  • To use Oauth2 package, create one more vault item and leave the content empty, your token credentials will be there after successful authorization.

  • Create the following flow by drag-and-dropping the nodes from the node palette, or by right clicking on the empty board. You can search the nodes by name.

Flow

  • Below is the list of nodes used in this flow:
  • Trigger -> Inject
  • Oauth2 -> Auth Code
  • Flow -> Stop
  • Click Auth Code Oauth node then set Credentials to the document item which contains your credentials and set Empty Vault Item to your empty document item.

Spreadsheet URL

  • Run the flow, a browser page will be opened for authorization. After you successfully authorize your app, you can go back to your flow and check your empty vault, it should be filled with your token credentials.
  1. Create a Team
  • Create the following flow by drag-and-dropping the nodes from the node palette, or by right clicking on the empty board. You can search the nodes by name.

Flow

  • Below is the list of nodes used in this flow:
  • Trigger -> Inject
  • Microsoft Teams -> Connect
  • Microsoft Teams -> Create Team
  • Microsoft Teams -> Disconnect
  • Programming -> Debug
  • Click Connect node then set Credential to the vault item of your token credentials.

  • Click Create Team node then set Display Name and Description of your team.

Credentials

note

You need to have at least Team.Create permission to perform this operation.

  • Run the flow. After this you can see your newly created team in Teams app.

Newly Created Team

  1. Create a Channel and Send a Message
  • Create the following flow by drag-and-dropping the nodes from the node palette, or by right clicking on the empty board. You can search the nodes by name.

Flow

  • Below is the list of nodes used in this flow:
  • Trigger -> Inject
  • Microsoft Teams -> Connect
  • Microsoft Teams -> Create Channel
  • Microsoft Teams -> Send Message
  • Microsoft Teams -> Disconnect
  • Flow -> Stop
  • Click Connect node then set Credentials to the vault item of your token credentials.

  • Click Create Channel node then set Team Id, Display Name and Description of your channel.

note

You can get your team's id from the Teams app by using link of the team (group id parameter of url is the id of team) or you can use List Teams node.

Create Team

note

You need to have at least Channel.Create permission to perform this operation.

  • Click Send Message node then set fields as shown.

Send Message

note

You need to have at least ChannelMessage.Send permission to perform this operation.

  • Run the flow. After this you can see your newly created channel and the message in Teams app.

Newly Created Team