MicrosoftTeamsAzureFunctionBot.mp4
This sample uses TypeScript, Azure Functions and Teams Toolkit for Visual Studio Code.
It aims to provide the basis of a skeleton project that demonstrates common bot features.
- Send proactive messages
- Send welcome message
- Use bot commands
- Capture user input
- Persist bot state
- Single sign-on (SSO)
Bots can use interactive cards, so it shows how to send:
- An Adaptive Card form to all bot install locations
- An Adaptive Card form to a specific person
- An Adaptive Card form using a bot command
Bots can capture user input, so its how to:
- Get user input from an Adaptive Card form
- Replace Adaptive Card form on form submit
Bots are stateful, so it shows how to:
- Use Azure Storage for notification state
- Use Azure Storage for conversation state
- Clear state using
/
command - Get and update state values
Bots can be friendly, so it shows how to:
- Send a welcome message to new users
Bots can handle authentication, so it shows how to:
- Obtain an access token from Azure AD using an Adaptive Card
- Exchange an access token for a Microsoft Graph bearer token
- Create a Microsoft Graph Client
- Make an authenticated request to Microsoft Graph using On-Behalf-Of flow
To run this sample you will need access to:
- Microsoft 365 tenant with uploading custom apps enabled
- Microsoft 365 account with admin permissions
Or use a Microsoft 365 Developer Tenant. Join the program today!
You will also need the following installed on your machine:
- Clone this repository
- Open the folder in Visual Studio Code
- Start a debug session, press F5 or use the Debug and Run panel
- Follow the on-screen steps to authenticate and add app to Microsost Teams.
- Stop debug session
- Update variables in
bot\src\.env.teamsfx.local
BLOB_CONNECTION_STRING=UseDevelopmentStorage=true
BLOB_CONTAINER_NAME_NOTIFICATIONS=notifications
BLOB_CONTAINER_NAME_STATE=state
- Start a new debug session, follow steps.
- Test the sample!
Send an Adaptive Card form to all install locations:
POST https://localhost:3798/api/notification
Send an Adaptive Card form to an specific person:
POST https://localhost:3798/api/notification?upn=user@domain.com
Post an Adaptive Card form using a command:
Send a message in the chat with the word form
.
Sign in and call Microsoft Graph:
Send a message in the chat with the word /signin
.
View access token:
Send a message in the chat with the word /token
.
Clear state:
Send a message in the chat with the word /clear
.