Microsoft-Teams-Samples: Automatic Installation of bot is not working while invoking from message extension

As per docs if we check the flow and show the adaptive card to add the bot in the corresponding context then it will automatically install the bot for us. Reference: https://learn.microsoft.com/en-us/microsoftteams/platform/messaging-extensions/how-to/action-commands/create-task-module?tabs=javascript#request-to-install-your-conversational-bot

Steps to Reproduce

  1. Clone https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-type-ahead-search-adaptive-cards/nodejs.
  2. Add messaging extension in manifest.json
"composeExtensions": [
    {
        "botId": "{{Microsoft-App-Id}}",
        "commands": [
        {
          "id": "requestFeedback",
          "type": "action",
          "title": "Request feedback",
          "description": "Request feedback",
          "initialRun": false,
          "fetchTask": true,
          "context": [
            "compose",
            "message"
          ]
        },
        ]
    }
  ],
  1. Add the following messaging extension invoke handler in TeamsBot
 handleTeamsMessagingExtensionFetchTask(
  context: TurnContext,
  action: MessagingExtensionAction
): Promise<MessagingExtensionActionResponse> {
  try {
    await TeamsInfo.getPagedMembers(context);
  } 
  catch (e) {
    return {
      task: {
        type: "continue",
        value: {
          card: CardFactory.adaptiveCard(
            AdaptiveCards.declare(cardWithInstallButton).render()
          ),
          
        },
      },
    };
  }
}

For me this adaptive card look like

{
  "type": "AdaptiveCard",
  "body": [
    {
      "type": "Container",
      "items": [
        {
          "type": "TextBlock",
          "text": "Add the bot",
          "wrap": true,
          "spacing": "Small",
          "horizontalAlignment": "Center",
          "size": "Large"
        }
      ]
    },
    {
      "type": "Container",
      "items": [
        {
          "type": "ActionSet",
          "actions": [
            {
              "type": "Action.Submit",
              "title": "Add the bot",
              "data": {
                "msteams": {
                  "justInTimeInstall": true
                }
              }
            }
          ],
          "spacing": "Large"
        }
      ],
      "separator": true,
      "spacing": "Large"
    }
  ],
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.3"
}

4.After this invoke command from message extension this will going to return the adaptive card with install button present in the same. 5. After Clicking on the same the bot should get install automatically and we receive the invoke action here in handler.

 public async handleTeamsMessagingExtensionSubmitAction(
    context: TurnContext,
    action: MessagingExtensionAction
  ): Promise<MessagingExtensionActionResponse> {
return {
      task: {
        type: "continue",
        value: {
          card: CardFactory.adaptiveCard(
            AdaptiveCards.declare(successCard).render()
          ),
          
        },
      },
    };
}

6.Issue is it come here but bot won’t get installed

Expected Behaviour Before invoke message with name = composeExtension/submitAction and value.data.msteams.justInTimeInstall = true. Bot should be get installed in the context. ie. Prior coming to this handler handleTeamsMessagingExtensionSubmitAction

Actual Behaviour We are getting invoke message in the handler handleTeamsMessagingExtensionSubmitAction but bot is not getting installed in the same.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16

Most upvoted comments

@arunagga - Glad to hear that your issue is resolved. Could you please share your valuable feedback here Microsoft Teams Developer Feedback.

Thanks @Nivedipa-MSFT , it worked for me now