MicrosoftDocs / msteams-docs

Source for the Microsoft Teams developer platform documentation.
https://aka.ms/teamsdev
Creative Commons Attribution 4.0 International
287 stars 510 forks source link

What determines when a card will be displayed as a card and when will it be listed? #656

Closed baruchiro closed 5 years ago

baruchiro commented 5 years ago

I see that when the title is a certain length, the cards cease to be buttons, and they are displayed as a numbered list within the message itself.

What sets it up?

And why?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Gousia-Begum commented 5 years ago

@baruchiro Can you please share a screenshot of the query you have?

baruchiro commented 5 years ago

Sure. I remember this from V4.3, but I can't find the code right now.

image

image

I used "very very" because a one "very" is still a card.

baruchiro commented 5 years ago

It need a more research. I see it shown differently in Facebook and Telegram

billbliss commented 5 years ago

Can you give us the JSON for the message you are sending?

baruchiro commented 5 years ago

JSON for the short message:

{
  "attachments": [],
  "channelId": "emulator",
  "conversation": {
    "id": "3e91a080-7a59-11e9-b27e-b7f2dc2a2f8f|livechat"
  },
  "entities": [],
  "from": {
    "id": "2",
    "name": "Bot",
    "role": "bot"
  },
  "id": "4279fe40-7a59-11e9-99a0-d9c48d8a8fbc",
  "inputHint": "acceptingInput",
  "localTimestamp": "2019-05-19T20:12:19+03:00",
  "locale": "",
  "recipient": {
    "id": "d1ff7fc6-7de6-4208-bed8-0dd025aaaa26",
    "role": "user"
  },
  "replyToId": "4240ece0-7a59-11e9-99a0-d9c48d8a8fbc",
  "serviceUrl": "https://a943a825.ngrok.io",
  "suggestedActions": {
    "actions": [
      {
        "title": "short title",
        "type": "imBack",
        "value": "recommendations"
      }
    ]
  },
  "text": "Hi, select what you want",
  "timestamp": "2019-05-19T17:12:19.748Z",
  "type": "message"
}

JSON for the long title:

{
  "attachments": [],
  "channelId": "emulator",
  "conversation": {
    "id": "9476c340-7a59-11e9-b916-434698c80b5d|livechat"
  },
  "entities": [],
  "from": {
    "id": "2",
    "name": "Bot",
    "role": "bot"
  },
  "id": "9a384dd0-7a59-11e9-a6cb-c56ac337ce96",
  "inputHint": "acceptingInput",
  "localTimestamp": "2019-05-19T20:14:46+03:00",
  "locale": "",
  "recipient": {
    "id": "d1ff7fc6-7de6-4208-bed8-0dd025aaaa26",
    "role": "user"
  },
  "replyToId": "99fea030-7a59-11e9-a6cb-c56ac337ce96",
  "serviceUrl": "https://8b80b63c.ngrok.io",
  "text": "Hi, select what you want\n\n   1. A very very long title",
  "timestamp": "2019-05-19T17:14:46.956Z",
  "type": "message"
}

And this is how I create the PromptOptions dialog:

internal PromptOptions CreateChoicesPromptOptions(string text, IDictionary<string, string> keyToTitle)
{
    return new PromptOptions
    {
        Prompt = MessageFactory.Text(text),
        Choices = keyToTitle.Select(v =>
            new Choice(v.Key)
            {
                Action = new CardAction(ActionTypes.ImBack, v.Value, value: v.Key)
            })
            .ToList()
    };
}
Gousia-Begum commented 5 years ago

@baruchiro image Suggested actions is not supported in Microsoft Teams. Could you please try using Cards and buttons?

baruchiro commented 5 years ago
  1. I didn't talk about Microsoft Teams. But maybe you mean a Bot Emulator is based on Microsoft Teams?
  2. I'm working with Bot Framework C# libraries. So the link that you have mentioned, just describe the JSON for Microsoft Teams, but the only documentation for C# and BotFramework 4 still used CardAction.
billbliss commented 5 years ago

I'm confused about your question. Is your question about how messages are rendered in the bot emulator? The documentation in this repository is for Microsoft Teams specifically. If you want to ask questions about the bot emulator, I'd suggest here: https://github.com/Microsoft/BotFramework-Emulator/issues

baruchiro commented 5 years ago

Oh sorry!

I didn't notice that this was a Microsoft Teams documentation, I thought I was in the BotFramework documentation.

Anyway, thanks for the help, I think you helped me understand that the question focuses on promptOption with ActionCards.