4 MS Teams setup
Wim edited this page 2020-01-01 22:11:48 +01:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

MSteams - mattermost - matterbridge integration

This is a complete walkthrough about how to setup an example mattermost <=> microsoft teams integration using matterbridge.

Please read everything very careful!

Go to Microsoft Azure portal

Go to App registrations

image

Create a new App registration

Click on New Registration (top)

image

Set Permissions

Click on View API Permissions (at the bottom)

image

Actually set permissions

  • Choose graph API
  • Choose delegated permissions
  • Add Group.Read.All, Group.ReadWrite.All and User.Read. These permissions are needed for sending/reading chat messages in a channel.
  • Add Files.Read, Files.Read.All, Sites.Read.All. These permissions are needed for reading the file attachments in messages.
image

This can take a while according to the message

image

You can now click on the Grant admin consent for yourorganization

image

Accept permissions

Youll get a popup with the permissions you just added. Agree

image

Wait again

This will take a few minutes again :)

image

Reload

Afterwards youll see green checkboxes for the permissions

image

Set redirect URI

This needs to be set otherwise the delegation doesnt work. Click on “Add a redirect URI”

image

Just fill in something like http://localhost:12345/matterbridge

image

Set application as public client

Scroll down a bit

Set Treat application as a public client. to Yes

image

Dont forget to click Save on top of the page

Get necessary IDs for matterbridge

ClientID and TenantID

Click on overview, left upper link.

Youll see 2 IDs, these are needed for the matterbridge configuration.

  • Tenant ID
  • Client ID
image

TeamID

Go to your teams website https://teams.microsoft.com should work.

Find your team, click on the 3 dots and select get link to team

image

This will get you a popup, click copy.

image

If you paste it youll get something like

https://teams.microsoft.com/l/team/19%3axxxxxxxxxxxxxxxxxc%40thread.skype/conversations?groupId=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&tenantId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

The groupID is the TeamID you need to configure matterbridge.

ChannelID

Next you have to decide which channel you want to bridge with for example mattermost.

In our setup we have the team matterbridge with 2 channels General (a default channel for every team) and newchannel one I created.

Youll find the channel ID in the URL in the threadId=19:82abcxxxxxxxxx@thread.skype

image

Note this ID 19:82abcxxxxxxxxx@thread.skype, we will need it when configuring the bridging.

Matterbridge configuration

Create an empty matterbridge.toml file

Configure teams in matterbridge

You should know have all the three IDs to configure matterbridge:

[msteams.teams]
TenantID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 
ClientID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
TeamID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "

add this to the matterbridge.toml file

Configure mattermost in matterbridge

See als the wiki

Configure this for your setup and add this to the matterbridge.toml file

[mattermost.mymattermost]
#The mattermost hostname. (do not prefix it with http or https)
Server="yourmattermostserver.domain:443"

#the team name as can be seen in the mattermost webinterface URL
#in lowercase, without spaces
Team="yourteam"

#login/pass of your bot.
#Use a dedicated user for this and not your own!
Login="yourlogin"
Password="yourpass"

RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
PrefixMessagesWithNick=true

Configure bridging channels

If you want to bridge the testing channel in mattermost with the general channel in msteams the configuration will look like this:

[[gateway]]
name="gw"
enable=true

[[gateway.inout]]
account = "mattermost.mymattermost"
channel = "testing"

[[gateway.inout]]
account="msteams.teams"
channel="19:82caxxxxxxxxxxxxxxxxxxxxxxxx@thread.skype"

The strange channel 19:82caxxxxxxxxxxxxxxxxxxxxxxxx@thread.skype can be found in this documentation at the ChannelID header above.

Once again the complete configuration

Your matterbridge.toml file should contain:

[msteams.teams]
TenantID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 
ClientID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
TeamID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "

[mattermost.mymattermost]
Server="yourmattermostserver.domain:443"
Team="yourteam"
Login="yourlogin"
Password="yourpass"
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
PrefixMessagesWithNick=true

[[gateway]]
name="gw"
enable=true

[[gateway.inout]]
account = "mattermost.mymattermost"
channel = "testing"

[[gateway.inout]]
account="msteams.teams"
channel="19:82caxxxxxxxxxxxxxxxxxxxxxxxx@thread.skype"

Starting matterbridge

Now you can start matterbridge by running matterbridge -conf matterbridge.toml

The first time you start matterbridge itll ask you to authenticate the app on behalf of you. You can do this from your own account or use a specific bot account for it.

Matterbridge can only read/send to the channels the account is in

[0003]  INFO router:       Starting bridge: msteams.teams
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code C8EGY6384 to authenticate.

Go to the URL as specified and enter the code.

image

Youll now get a popup to consent, this is everything that matterbridge has access to. For now itll only use read all groups and read and write all groups to read and send messages.

image

Afterwards you should see this window

image

And matterbridge will continue to start-up

Matterbridge by default will write a sessionfile containing tokens to the directory where matterbridge is running. Itll be a file called msteams_session.json. This files contains the necessary credentials so that matterbridge can restart/renew without asking the device login again.

Be sure to keep this file secure!

You can choose another path/filename, by adding SessionFile="yourfilename" to the [msteams.teams] configuration.