In order to create a bot you need to first register it in the Azure portal.
- Choose to Create a resource, or alternatively go to an existing resource group and click Add
- Search for Bot channels registration and then click Create
- Give the bot a handle (ex:
lookupBot
), choose your subscription and resource group - For the messaging endpoint, use this:
https://mcasmsgext.azurewebsites.net/api/messages
- Choose to Auto create Microsoft App ID and Password
- Click Create
- Wait for Azure to finish its magic and when done choose to go to resource
- On the bot page choose Channels and choose to add Microsoft Teams as a channel
- Next, choose the Settings and click on Manage next to Microsoft App Id
- In the Bot app portal, generate a new app password and store it securely - you will need them for your
.env
file or add them as application settings for the hosting web site (see below)
The App Id and App Secret, generated during the registration, for the bot are read from the MICROSOFT_APP_ID
and MICROSOFT_APP_PASSWORD
environment variables, specified in the .env
file. These can be configured in the Azure Web App under Application Settings > App Settings.
The bot can be tested and debugged locally using the gulp serve --debug
command and using the Microsoft Bot Framework Channel Emulator. You should also update the App Id and Password in the .env
file.
Another great way to test and debug bots running locally is to use ngrok along with gulp serve
. Ngrok allows you to create a secure tunnel from localhost to the Internet. Download and install ngrok, and then type ngrok http 3007
at a command prompt. Ngrok will start, and will create a tunnel between localhost:3007 and https://########.ngrok.io (the ######## will change every time you start ngrok). Run gulp serve
in another command prompt. Change your messaging endpoint in the Bot Framework portal to https://########.ngrok.io/api/messages. http://localhost:4040 will contain a log of all the traffic between your bot and Teams, and you can use a debugger such as Visual Studio Code to set breakpoints and examine variables.