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

MS Teams does not return Activity object when sending attachment list #6366

Closed
nonatoc opened this issue Aug 18, 2021 · 8 comments
Closed

MS Teams does not return Activity object when sending attachment list #6366

nonatoc opened this issue Aug 18, 2021 · 8 comments
Assignees
Labels
Bot Services Required for internal Azure reporting. Do not remove. Do not change color. bug Indicates an unexpected problem or an unintended behavior. customer-replied-to Indicates that the team has replied to the issue reported by the customer. Do not delete. customer-reported Issue is created by anyone that is not a collaborator in the repository. needs-triage The issue has just been created and it has not been reviewed by the team.

Comments

@nonatoc
Copy link

nonatoc commented Aug 18, 2021

Version

4

Describe the bug

Hey guys

I have a use case where I need to send to the user 2 messages: the first one is a heroCard with a survey question statement and the second one is a list of heroCards with the options.

The code to achieve that is this:

          // ============================
          // SEND QUESTION
          // ============================
          var questionCard = CardFactory.heroCard('Question 1', 'Question statement');
          var message1 = MessageFactory.attachment(questionCard)
          var activity1 = await context.sendActivity(message1)

          // print the Activity Object
          console.log('activity1: ', JSON.stringify(activity1))


          // ============================
          // SEND OPTIONS
          // ============================
          var options = [
            CardFactory.heroCard('', [],
              [{
                type: ActionTypes.ImBack,
                title: '🙁 Disagree',
                value: '1'
              }]
            ),
            CardFactory.heroCard('', [],
              [{
                type: ActionTypes.ImBack,
                title: '🙂 Agree',
                value: '2',
              }]
            )
          ]

          var activity2 = await context.sendActivity({
            attachments: options,
            attachmentLayout: AttachmentLayoutTypes.List
          })

          // print the Activity Object
          console.log('activity2: ', JSON.stringify(activity2))

          await next();
        });

You may ask: why not just use the "buttons" property of the first heroCard? I can't, because one of the requests is to show the options vertically (stacked).

It displays the options correctly, as I show in the print bellow
image

The problem is that I need to capture the ActivityId of the second message (with the options) so then I can hide it (using updateActivity) when the user select one option.

But, for some weird reason it does not work properly in MS Teams, however it works very well in Slack, as you can see in the print bellow!
image

PS: I don't know if it can helps, but if I change the "attachmentLayout" from "list" to "carousel", the ActitiyId is generated correctly in MS Teams, as shown below:
image

Please, can you guys help me?

Thanks in advance.

Expected behavior

It should show the activity object properly

@nonatoc nonatoc 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 Aug 18, 2021
@stevkan stevkan added Bot Services Required for internal Azure reporting. Do not remove. Do not change color. customer-reported Issue is created by anyone that is not a collaborator in the repository. labels Aug 19, 2021
@jwiley84
Copy link

Hi @nonatocosta !

I'm working on a repo of this to see what's going, and possibly reach out the Teams or Services team once I've narrowed it down. In the mean time, I was curious to see if you'd tried adaptive cards instead of hero cards. Their functionality should allow for vertically stacked buttons in both channels like what you're describing:

https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-reference

@joshgummersall joshgummersall assigned jwiley84 and unassigned stevkan Aug 20, 2021
@nonatoc
Copy link
Author

nonatoc commented Aug 20, 2021

Hi @jwiley84 , thanks for the answer and the attention with my issue.

I had already tried adaptive cards, but it does not seem to work well with Slack, because, instead of the card with the buttons, it renders an image "emulating" the card.

Apparently adaptive cards only work with MS Teams.

But again, thank you very much

@tracyboehrer tracyboehrer added the customer-replied-to Indicates that the team has replied to the issue reported by the customer. Do not delete. label Aug 23, 2021
@jwiley84
Copy link

Apologies for the delay.

It would seem that Teams is splitting the attachment into 2 activities, and as the api only supports returning one activity ID, it's returning none.

Could you split the attachment up into single cards, send them individually, and track the activity ID that way?

@nonatoc
Copy link
Author

nonatoc commented Aug 24, 2021

Hi, no worries

thank you for your attention.

I can do that, the only issue is that if I have 5 options, for example, I'll need to deal with 6 different activities ID's (1 for the question + 5 options) in order to hide the options after the user select one.

May this cause some kind of weird behavior?

As you can see, if I change the style to 'carousel' instead of 'list', this problem does no happen.

thank you very much

@jwiley84
Copy link

I'll reach out to the Teams team regarding the .list issue. This is something happening on their end.

@nonatoc
Copy link
Author

nonatoc commented Aug 27, 2021

ok, thank you

@a-b-r-o-w-n
Copy link
Contributor

@clearab Is this something that should be transferred to the Teams team?

@clearab
Copy link
Contributor

clearab commented Sep 7, 2021

This is a known limitation in Teams, and message splitting is the culprit. Carousel is creating a single message in Teams, with a single ID. List is creating multiple messages, each with their own ID (that unfortunately aren't all given back to the bot developer). The only real option unfortunately is to send multiple separate cards, or go send a single card with multiple buttons and be ok with the horizontal alignment.

If you'd like to reach out to the Teams group directly to give them additional feedback on this, you can do so through one of the options outlined here: https://aka.ms/teamsdevfeedback. I'll also share this Issue with them.

@clearab clearab closed this as completed Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bot Services Required for internal Azure reporting. Do not remove. Do not change color. bug Indicates an unexpected problem or an unintended behavior. customer-replied-to Indicates that the team has replied to the issue reported by the customer. Do not delete. customer-reported Issue is created by anyone that is not a collaborator in the repository. 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

6 participants