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.
-
Sign in to the Azure portal.
-
From your registered application's overview page, copy the Application (client) ID.
- Click Endpoints and copy your OAuth 2.0 authorization endpoint (v2) as auth_uri and OAuth 2.0 token endpoint (v2) as token_uri.
- In the left-hand navigation panel, click Certificates & secrets then click New client secret.
- Enter a description for your secret and choose expiration then click Add.
- Copy the value of it, this will be your client secret.
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.
- 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 ).
- Click "Create Item" and then "Document Item".
- Give a name to your Vault Item.
- Document item has Filename and Content sections give a name to this file and set a json for content as shown with your credentials.
"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.
-
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.
- 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.
- 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.
- 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.
- 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.
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.
- 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.
- 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.
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.
You need to have at least Channel.Create permission to perform this operation.
- Click Send Message node then set fields as shown.
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.