Capstone project creating MS Teams POC app
Below are the steps required to install, setup, and run the MS Teams App for a local development environment.
- Sign up for a Microsoft Developer account here. This account will be used by Microsoft and Azure throughout the development process.
- In VS Code, navigate to the Extensions Marketplace and look for "Teams Toolkit". You can also install it by navigating to the following link: Teams Toolkit
- Once the extension has been installed, navigate to the newly created tab on the left side of VSCode. If you don't see the Teams Toolkit tab, you may need to restart VSCode.
- In the Teams Toolkit tab, under the Accounts section, login to Microsoft 365 and Azure using your Microsoft developer account.
- Clone the repo to the directory of your choice.
- Open the newly installed repo folder in VSCode by going to File > Open Folder... then select the repo folder (msteams-poc). NOTE You may get prompted by VSCode to trust the developers of the files for that directory.
- Once the folder has been loaded, you should be able to run the bot by pressing F5. This will open a new instance of Edge or Chrome and allow you to start testing the bot.
- Once Edge or Chrome has opened, you will then be prompted on where to install the app. Click the dropdown beside the "Add" button and select "Add to a team". From there you can select what Team to install the app to.
- Refer to the Known Issues/Best Practices section below for more information about running the bot and some possible issues.
-
The Teams Toolkit tends to sign you out of your accounts. This causes several issues including a subscription error. It's best practice if you check your accounts login status before attempting the run the bot.
-
When multiple people are working on the bot at the same time, it's best to use your own Team for development. If multiple people add the bot to the same team it becomes difficult to differentiate between who's bot is who's. Even when you stop debugging and disable the bot, it stays in the team as an App (just without any functionality). One way to counteract this is to change the name of the bot in the .fx/manifest.source.json under name > short. I used Metl-tyson so that it was obviously my local debug version.
-
When working with the bot, ensure the Metl API is running. Now that the API has been fully integrated with the bot it perform requests when events are fired in Teams like: Channels added/updated/deleted, Members added/removed, etc.
You can use something like postman and send a POST request to the /proactivemessage endpoint with a body containing a type, text, targets, and choices (if testing a multi-choice question). For the targets field, you MUST send an entire object of either a channel or user, this can be obtained for the Organization in the Metl API. Refer to the samples below:
{
"id": "user-id",
"name": "John Doe",
"objectId": "object-id",
"givenName": "John",
"surname": "Doe",
"email": "[email protected]",
"userPrincipalName": "[email protected]",
"tenantId": "tenant-id",
"userRole": "user",
"aadObjectId": "aadobject-id"
}
{
"id": "channel-id",
"name": "channel-name"
}
{
"type": "Message",
"text": "This is a sample message directly from postman.",
"targets": [
{
"id": "channel-id",
"name": "channel-name"
}
]
}
{
"type": "YesNo",
"text": "Do you like dogs?",
"targets": [
{
"id": "channel-id",
"name": "channel-name"
}
]
}
{
"type": "MultiChoice",
"text": "What is your favourite household pet?",
"choices": [
{
"title": "Dog",
"value": "dog"
},
{
"title": "Cat",
"value": "cat"
},
{
"title": "Fish",
"value": "fish"
}
],
"targets": [
{
"id": "channel-id",
"name": "channel-name"
}
]
}
{
"type": "TextBlock",
"text": "Thoughts on dogs?",
"targets": [
{
"id": "channel-id",
"name": "channel-name"
}
]
}
{
"type": "Number",
"text": "What is 3+2?",
"targets": [
{
"id": "channel-id",
"name": "channel-name"
}
]
}