page_type | description | urlFragment | products | languages | extensions | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
A task module allows you to create modal popup experiences in your Teams application. |
ms-teams-task-sample |
|
|
|
A task module allows you to create modal popup experiences in your Teams application. Inside the popup, you can run your own custom HTML/JavaScript code, show an <iframe>
-based widget such as a YouTube or Microsoft Stream video, or display an Adaptive card.
Task modules build on the foundation of Microsoft Teams tabs: a task module is essentially a tab in a popup window. It uses the same SDK, so if you've built a tab you are already 90% of the way to being able to create a task module.
Note these instructions are for running the sample on your local machine, the tunnelling solution is required because the Teams service needs to call into the bot.
In Azure portal, create a Azure Bot resource.
- Ensure that you've enabled the Teams Channel
-
Clone the repository
git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
-
In a terminal, navigate to
samples/app-task-module/nodejs
-
Run ngrok - point to port 3978
ngrok http -host-header=rewrite 3978
-
Modify the /web.config and fill in the {{ MicrosoftAppId }},{{ MicrosoftAppPassword }} with the id from step 1 and {{BaseUrl}} we get from previous step. ngrok BaseUrl will look something like
https://abc21-hun-12ef.ngrok.io
. -
In a terminal, navigate to
BotWithSharePointFileViewer
# change into project folder cd # BotWithSharePointFileViewer
-
Run the bot from a terminal or from Visual Studio, choose option A or B.
A) From a terminal
# run the bot
dotnet run
B) Or from Visual Studio
- Launch Visual Studio
- File -> Open -> Project/Solution
- Navigate to
samples/bot-sharepoint-file-viewer/csharp
folder - Select
BotWithSharePointFileViewer.csproj
file - Press
F5
to run the project
To learn more about deploying a bot to Azure, see Deploy your bot to Azure for a complete list of deployment instructions.
- A personal app. When you upload the Task Module CSharp.zip file, choose "Add for you" and "Task Module CSharp" will appear in the "..." menu in the Teams app bar. The personal app has both a tab and a bot.
- A channel tab. Add the app to a team, then add a Task Module CSharp tab and choose "Task Module Demo" from the radio button list.
- A channel bot. Add the app to a team, then chat with it (@Task Module CSharp).
The tab shows how to invoke the task module using the Teams SDK. Source code for the tab is found in Tasks.cshtml.
The following task modules are supported:
- YouTube, which is comprised of a generic template for embedded
<iframe>
experiences (also used for the PowerApp task module below) plus a one-line stub containing the YouTube embed URL - PowerApp — unfortunately it doesn't work out of the box; click the button or see the source code for details on how you can customize it for your tenant
- There are two custom form examples:
- Showing the results of a custom form returned to the tab
- Showing the results of a custom form returned to the bot
- There are two Adaptive card examples:
- Showing the results of an
Action.Submit
button returned to the tab - Showing the results returned to the bot as a message
- Showing the results of an
The sample app also contains a bot with cards allowing you to invoke these task modules. You can invoke them from an Adaptive card or from a Bot Framework thumbnail card. RootDialog.cs contains the code for the cards, and MessagesController.cs contains the code for responding to task/fetch
and task/submit
messages.
- Metadata used to generate TaskInfo objects is in TaskModel.cs.
- Model classes for handling Bot Framework card actions vs. Adaptive card Action.Submit actions are defined in CardActionValue.cs
- Deeplink is generated in DeeplinkHelper.cs
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.