Skip to content

Latest commit

 

History

History
137 lines (66 loc) · 3.7 KB

Microsoft-Teams.md

File metadata and controls

137 lines (66 loc) · 3.7 KB

Spring-Bot With Microsoft Teams Tutorial

Create a Teams Developer Account

You can apply for a 90-day developer account that allows you to set up an instance of Microsoft Teams with up to 20 different users. This allows you to work with colleagues to build and test a bot.

  • You can apply for this here

Developer Program

  • Create some user accounts and distribute them to your friends.

Accounts

  • With your own account, you should be able to log into Microsoft Teams with your onmicrosoft.com email:

Login

  • From here, you can explore the delights of Microsoft Teams, and talk to any friends you invited.

Create an App Manifest on The Teams Developer Portal

You can access the Teams Developer Portal here.

We are going to create an App, which is something that is available in the Teams App Store, and can be installed into your Teams chats. An App can contain a number of bots. Here, we'll just create one.

  • Click New App

  • Name The App

  • Select App Features

App Features

  • Click "Bot"

Identify Bot

  • Create a new bot and give the bot a name

  • Create a Client Secret, and keep this somewhere

  • Fill out the privacy policy, terms of use:

Privacy Policy and Terms Of Use

  • Give The App Some permissions

Teams Perms

Note, we are going crazy here and giving all the permissions. You might well want to reduce the number available. But, start with this as it might otherwise lead to problems later.

Chat Perms

  • Publish The App To Your Organisation

Publish App

Approve The App In The Teams Admin Console

Before you can see the App in the Teams App Store, it needs to be approved (published) by your Teams administrators.

The Admin Console has a "Manage Apps" section here.

  • Approve your new app by searching for it in the list

  • Change Publishing Status to "Published"

Moving App To Published

Configuring The Bot

We're going to set up a bot running on the localhost, and then use ngrok to port-forward the bot onto the internet, running in HTTPS with a proper certificate. From there, we can get Microsoft Teams to talk to it.

A Simple Bot

  • Set up the bot, TBC.

  • Add AppId, Password to the config

  • Start the bot:

Spring Startup

NGrok port Forwarding

Since your bot is running on localhost, Microsoft Teams can't access it. However, we can use ngrok to tunnel onto the public internet.

  • Install ngrok from here

  • Start like this:

ngrok http 8080

  • It will start a process like so:

ngrok

Configure Teams Bot Endpoint

Now, we need to configure our Bot in Microsoft Teams to send messages to this endpoint. For that, we go back into the Developer Portal, and find the Bot:

Bot Properties

  • Set the bot endpoint to use your https ngrok endpoint, with the path /api/messages.

Bot Endpoint

  • At this point, you will probably need to restart teams, to clear the cache of the App Store.

  • Go back to Teams and find the App in the App Store.

App In AppStore

  • Add it to a team

Open Options

  • Choose Your Team

Choose Team

Talk With Your Bot

Talk To The Bot