Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaptive card reverting back after reacting to it in Teams #4635

Open
qinezh opened this issue Mar 19, 2024 · 0 comments
Open

Adaptive card reverting back after reacting to it in Teams #4635

qinezh opened this issue Mar 19, 2024 · 0 comments
Labels
bug Indicates an unexpected problem or an unintended behavior. needs-triage The issue has just been created and it has not been reviewed by the team.

Comments

@qinezh
Copy link
Contributor

qinezh commented Mar 19, 2024

Versions

SDK version: 4.22.1
Platform: Teams

Describe the bug

I have created a Teams bot that supports:

  1. return an adaptive card when command received.
  2. return another adaptive card as invoke response when Action.Execute action is executed.

However, the card (step 2) reverted back to the previous one (step 1) after reacting to it. The issue occurs both in classic Teams and new Teams.

To Reproduce

Below's the test code with botbuilder SDK
import {
  ActivityTypes,
  CardFactory,
  MessageFactory,
  StatusCodes,
  TeamsActivityHandler,
  TurnContext,
} from "botbuilder";

export class TeamsBot extends TeamsActivityHandler {
  constructor() {
    super();

    this.onMessage(async (context, next) => {
      console.log("Running with Message Activity.");
      const card = CardFactory.adaptiveCard({
        "type": "AdaptiveCard",
        "body": [
          {
            "type": "TextBlock",
            "size": "Medium",
            "weight": "Bolder",
            "text": "Click button"
          },
          {
            "type": "ActionSet",
            "actions": [
              {
                "type": "Action.Execute",
                "verb": "doStuff",
                "title": "DoStuff"
              }
            ]
          }
        ],
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "version": "1.4"
      });

      const message = MessageFactory.attachment(card)
      await context.sendActivity(message);

      await next();
    });

    this.onTurn(async (context: TurnContext, next: () => Promise<void>) => {
      if (context.activity.name === "adaptiveCard/action") {
        const action = context.activity.value.action;
        const actionVerb = action.verb;

        if (actionVerb?.toLowerCase() === "dostuff") {
          const card = {
            "type": "AdaptiveCard",
            "body": [
              {
                "type": "TextBlock",
                "size": "Medium",
                "weight": "Bolder",
                "text": "✅[ACK]"
              },
              {
                "type": "TextBlock",
                "text": "Congratulations! Your task is processed successfully.",
                "wrap": true
              }
            ],
            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
            "version": "1.4"
          };

          const response = {
            status: StatusCodes.OK,
            body: {
              statusCode: StatusCodes.OK,
              type: "application/vnd.microsoft.card.adaptive",
              value: card,
            },
          };
          await context.sendActivity({
            type: ActivityTypes.InvokeResponse,
            value: response,
          });
        }
      }

      await next();
    })
  }
}

Expected behavior

The adaptive cards won't be reverted after reactions.

Screenshots

ACCard-issue-on-reaction.mp4
@qinezh qinezh added bug Indicates an unexpected problem or an unintended behavior. needs-triage The issue has just been created and it has not been reviewed by the team. labels Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or an unintended behavior. needs-triage The issue has just been created and it has not been reviewed by the team.
Projects
None yet
Development

No branches or pull requests

1 participant