Skip to content

Latest commit

 

History

History

README.md

page_type sample
description Demonstrating on how to implement sequential flow, user specific view and up-to-date adaptive cards in bot.
products
office-teams
office
office-365
languages
python
extensions
contentType createdDate
samples
05-05-2025 13:38:25
urlFragment officedev-microsoft-teams-samples-bot-sequential-flow-adaptive-cards-python

Bot Sequential Flow Adaptive Cards

Demonstrating on how to implement sequential flow, user specific view and up-to-date adaptive cards in bot.

Key features

  • Incident Creation
    • Choose Category
    • Choose Sub Category
    • Create Incident
    • Edit/ Approve/ Reject Incident
  • List Incidents

Included Features

  • Bots
  • Adaptive Cards

Interaction with app

Bot Adaptive ActionsGif

Try it yourself - experience the App in your Microsoft Teams client

Please find below demo manifest which is deployed on Microsoft Azure and you can try it yourself by uploading the app package (.zip file link below) to your teams and/or as a personal app. (Sideloading must be enabled for your tenant, see steps here).

Sequential workflow adaptive cards: Manifest

This App talks about the Teams Bot User Specific Views and Sequential Workflows in adaptive card with python

This bot has been created using Bot Framework v4, it shows how to create a simple bot that accepts food order using Adaptive Cards V1.4

This is a sample app that provides an experience of managing incidents. This sample makes use of Teams platform capabilities like Universal Bots with below mentioned capabilities. User Specific Views Sequential Workflows Up to date cards

Prerequisites

  • Microsoft Teams is installed and you have an account
  • Python SDK min version 3.6
  • dev tunnel or ngrok latest version or equivalent tunnelling solution

Run the app (Using Microsoft 365 Agents Toolkit for Visual Studio Code)

The simplest way to run this sample in Teams is to use Microsoft 365 Agents Toolkit for Visual Studio Code.

  1. Ensure you have downloaded and installed Visual Studio Code
  2. Install the Microsoft 365 Agents Toolkit extension and Python Extension
  3. Select File > Open Folder in VS Code and choose this samples directory from the repo
  4. Press CTRL+Shift+P to open the command box and enter Python: Create Environment to create and activate your desired virtual environment. Remember to select requirements.txt as dependencies to install when creating the virtual environment.
  5. Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps
  6. Select Debug > Start Debugging or F5 to run the app in a Teams web client.
  7. In the browser that launches, select the Add button to install the app to Teams.

If you do not have permission to upload custom apps (sideloading), Microsoft 365 Agents Toolkit will recommend creating and using a Microsoft 365 Developer Program account - a free program to get your own dev environment sandbox that includes Teams.

Run the app (Manually Uploading to Teams)

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.

  1. Clone the repository

    git clone https://github.com/OfficeDev/Microsoft-Teams-Samples.git
  2. Run ngrok - point to port 3978

    ngrok http 3978 --host-header="localhost:3978"

    Alternatively, you can also use the dev tunnels. Please follow Create and host a dev tunnel and host the tunnel with anonymous user access command as shown below:

    devtunnel host -p 3978 --allow-anonymous
  3. Register a new application in the Microsoft Entra ID – App Registrations portal.

A) Select New Registration and on the register an application page, set following values: * Set name to your app name. * Choose the supported account types (any account type will work) * Leave Redirect URI empty. * Choose Register. B) On the overview page, copy and save the Application (client) ID, Directory (tenant) ID. You'll need those later when updating your Teams application manifest and in the appsettings.json. C) Navigate to API Permissions, and make sure to add the following permissions: Select Add a permission * Select Add a permission * Select Microsoft Graph -> Delegated permissions. * User.Read (enabled by default) * Click on Add permissions. Please make sure to grant the admin consent for the required permissions.

  1. Create Azure Bot resource resource in Azure

    • Use the current https URL you were given by running the tunneling application. Append with the path /api/messages used by this sample
    • Ensure that you've enabled the Teams Channel
    • If you don't have an Azure account you can use this Azure free account here
  2. In a terminal, go to samples\bot-sequential-flow-adaptive-cards/python

  3. Activate your desired virtual environment

  4. Install dependencies by running pip install -r requirements.txt in the project folder.

  5. Update the config.py configuration for the bot to use the Microsoft App Id and App Password from the Bot Framework registration. (Note the App Password is referred to as the "client secret" in the azure portal and you can always create a new client secret anytime.)

  6. This step is specific to Teams.

    • Edit the manifest.json contained in the appManifest folder to replace your Microsoft App Id (that was created when you registered your bot earlier) everywhere you see the place holder string ${{AAD_APP_CLIENT_ID}} and ${{TEAMS_APP_ID}} (depending on the scenario the Microsoft App Id may occur multiple times in the manifest.json)
    • Zip up the contents of the appManifest folder to create a manifest.zip
    • Upload the manifest.zip to Teams (in the Apps view click "Upload a custom app")
  • Upload the manifest.zip to Teams (in the Apps view click "Upload a custom app")
    • Go to Microsoft Teams. From the lower left corner, select Apps
    • From the lower left corner, choose Upload a custom App
    • Go to your project directory, the ./appManifest folder, select the zip folder, and choose Open.
    • Select Add in the pop-up dialog box. Your app is uploaded to Teams.

Workflows

Workflow for bot interaction

sequenceDiagram
    participant Teams User B    
    participant Teams User A
    participant Teams Client
    Teams User A->>+Teams Client: Enters create incident bot commands
    Sample App->>+Teams Client: loads card with option 
    Teams User A->>+Teams Client: Enters required details and assigns to user B
    Sample App-->>Teams Client: Posts the incidnet card with auto-refresh for user A and user B
    Teams Client->>Teams User A: loads incident card with loading indicator 
    Teams Client->>Sample App: Automatically invokes refresh action
    Sample App-->>Teams User A: Responds with Updated AC for the user A
    Teams User B->>Teams Client: User opens the chat
    Teams Client-->>Teams User B: Loads the incident base card
    Teams Client->>Sample App: Automatically invokes refresh action
    Sample App-->>Teams User B: Responds with card for user B with option to approve/reject
Loading

Workflow for messaging extension interaction

sequenceDiagram
    participant Teams User B    
    participant Teams User A
    participant Teams Client
    Teams User A->>+Teams Client: Clicks on Incidents ME action in a group chat
    opt App not installed flow
        Teams Client-->>Teams User A: App install dialog
        Teams User A->>Teams Client: Installs app
    end   
    Teams Client->>+Sample App: Launches Task Module
    Sample App-->>-Teams Client: Loads existing incidents created using Bot
    Teams User A->>Teams Client: Selects incident to share in chat
    Teams Client->>Sample App: Invoke action callback composeExtension/submitAction
    Sample App-->>Teams Client: Posts Base card with auto-refresh for user A and user B
    Teams Client->>Teams User A: loads incident card with loading indicator 
    Teams Client->>Sample App: Automatically invokes refresh action
    Sample App-->>Teams User A: Responds with Updated AC for the user A
    Teams User B->>Teams Client: User opens the chat
    Teams Client-->>Teams User B: Loads the incident base card
    Teams Client->>Sample App: Automatically invokes refresh action
    Sample App-->>Teams User B: Responds with card for user B with option to approve/reject
Loading
  1. Run your bot with python app.py

Running the sample

Install App:

InstallApp

InstallApp

Welcome UI:

Type in Chat: @Sequential Workflows (BotName) and Enter

Initial message

Running Sample

Running Sample

Running Sample

Running Sample

Running Sample

Running Sample

Running Sample

Running Sample

Running Sample

Running Sample

Running Sample

Approve or Reject Incidents

Only the Assigned To person have the option to Approve or Reject

Running Sample

Running Sample

Running Sample

List Incidents

Running Sample

Interaction from messaging extension.

You can also interact with this app using messaging extension action which allows you to share incidents in group chats.

  1. On selecting app from messaging extension,it checks whether bot is installed in chat/team. If not installed, user will get a option for justInTimeInstallation card.

    just in time installation card

  2. After successful installation, list of all incidents will be available in messaging extension.

    incident list card.

  3. Users can select any incident from the list and share it to that chat or team.

    image

Further reading