MicrosoftDocs / msteams-docs

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

[Rendering] Typeahead provides incorrect "top" for Input.ChoiceSet #6484

Open Wajeed-msft opened 2 years ago

Wajeed-msft commented 2 years ago

Copied bug from: https://github.com/microsoft/AdaptiveCards/issues/7686

Details from original post:

Target Platforms

Microsoft Teams app as well as website, on both Windows and MacOS.

SDK Version

1.5

Application Name

Microsoft Teams

Problem Description

When an Adaptive Card's Input.ChoiceSet has Typeahead settings provided, the "count" field is expected to be set to the "top" of the invoke to the backend. However, the "top" in the invoke is always set to the 15 rather than the value specified by "count".

For example, in the provided sample curl command and card JSON, we would expect the "invoke" to the backend to request 100 choices, not 15.

Here is the "invoke" request sent to the backend after typing the letter "b" into the Input.ChoiceSet:

{
    "name": "application/search",
    "type": "invoke",
    "timestamp": "2022-07-18T12:08:18.197Z",
    "localTimestamp": "2022-07-18T13:08:18.197+01:00",
    "id": "...",
    "channelId": "msteams",
    "serviceUrl": "https://smba.trafficmanager.net/amer/",
    "from": {
        "id": "...",
        "name": "...",
        "aadObjectId": "..."
    },
    "conversation": {
        "conversationType": "personal",
        "tenantId": "...",
        "id": "..."
    },
    "recipient": {
        "id": "...",
        "name": "..."
    },
    "entities": [
        {
            "locale": "en-US",
            "country": "US",
            "platform": "Web",
            "timezone": "Europe/Dublin",
            "type": "clientInfo"
        }
    ],
    "channelData": {
        "tenant": {
            "id": "..."
        },
        "source": {
            "name": "message"
        },
        "legacy": {
            "replyToId": "..."
        }
    },
    "replyToId": "...",
    "value": {
        "queryText": "b",
        "queryOptions": {
            "skip": 0,
            "top": 15
        },
        "dataset": "fruits"
    },
    "locale": "en-US",
    "localTimezone": "Europe/Dublin"
}

Screenshots

No response

Card JSON

{
    "contentType": "application/vnd.microsoft.card.adaptive",
    "content": {
        "type": "AdaptiveCard",
        "version": "1.5",
        "body": [
            {
                "size": "large",
                "text": "Pick a Fruit",
                "weight": "bolder",
                "type": "TextBlock"
            },
            {
                "choices": [
                    {
                        "title": "Apple",
                        "value": "1"
                    },
                    {
                        "title": "Banana",
                        "value": "2"
                    },
                    {
                        "title": "Banana",
                        "value": "3"
                    },
                    {
                        "title": "Pear",
                        "value": "4"
                    }
                ],
                "id": "fruit",
                "isRequired": true,
                "label": "Fruit",
                "style": "filtered",
                "type": "Input.ChoiceSet",
                "choices.data": {
                    "type": "Data.Query",
                    "dataset": "fruits",
                    "count": 100
                }
            }
        ],
        "actions": [
            {
                "data": {
                    "command": "fruit"
                },
                "title": "Submit",
                "type": "Action.Execute"
            }
        ],
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
    },
    "properties": {}
}

Sample Code Language

Curl

Sample Code


# The following curl command creates an Adaptive Card with the problematic rendering.
# $TEST_BOT_ID = the Microsoft Teams bot id to test with
# $CONVERSATION_ID = the Microsoft Teams conversation to send the card to
# $TOKEN = the Microsoft token received from https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token
curl -d '{
    "type": "message",
    "timestamp": "2022-07-06T12:16:08.067226Z",
    "from": {
        "id": "$TEST_BOT_ID",
        "properties": {}
    },
    "conversation": {
        "isGroup": false,
        "id": "$CONVERSTION_ID",
        "properties": {}
    },
    "historyDisclosed": false,
    "attachments": [
        {
            "contentType": "application/vnd.microsoft.card.adaptive",
            "content": {
                "type": "AdaptiveCard",
                "version": "1.5",
                "body": [
                    {
                        "size": "large",
                        "text": "Pick a Fruit",
                        "weight": "bolder",
                        "type": "TextBlock"
                    },
                    {
                        "choices": [
                            {
                                "title": "Apple",
                                "value": "1"
                            },
                            {
                                "title": "Banana",
                                "value": "2"
                            },
                            {
                                "title": "Banana",
                                "value": "3"
                            },
                            {
                                "title": "Pear",
                                "value": "4"
                            }
                        ],
                        "id": "fruit",
                        "isRequired": true,
                        "label": "Fruit",
                        "style": "filtered",
                        "type": "Input.ChoiceSet",
                        "choices.data": {
                            "type": "Data.Query",
                            "dataset": "fruits",
                            "count": 100
                        }
                    }
                ],
                "actions": [
                    {
                        "data": {
                            "command": "fruit"
                        },
                        "title": "Submit",
                        "type": "Action.Execute"
                    }
                ],
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
            },
            "properties": {}
        }
    ],
    "entities": [],
    "properties": {}
}' -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" 'https://smba.trafficmanager.net/amer/v3/conversations/$CONVERSATION_ID/activities'
```---
#### Document Details

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

* ID: 3fb4394d-25b1-8752-3996-fe3a2934732d
* Version Independent ID: 6d391381-89d0-117c-27cc-00043bd26a36
* Content: [Cards reference - Teams](https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-reference)
* Content Source: [msteams-platform/task-modules-and-cards/cards/cards-reference.md](https://github.com/MicrosoftDocs/msteams-docs/blob/master/msteams-platform/task-modules-and-cards/cards/cards-reference.md)
* Product: **msteams**
* GitHub Login: @surbhigupta12
* Microsoft Alias: **surbhigupta12**
ghost commented 2 years ago

Hi Wajeed-msft! Thank you for bringing this issue to our attention. We will investigate and if we require further information we will reach out in one business day. Please use this link to escalate if you don't get replies.

Best regards, Teams Platform

sayali-MSFT commented 2 years ago

@thomasylee - We will look into it and get back to you.

sayali-MSFT commented 2 years ago

@thomasylee -Could you please elaborate more on curl command? Also We have sample here ,We are tried this one to repro the scenario but it's working fine as expected, Could you please check it once? Sample Link-https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-type-ahead-search-adaptive-cards/csharp

thomasylee commented 2 years ago

The curl command sends an Adaptive Card to a conversation in Microsoft Teams. The card shows a filtered Input.ChoiceSet with Typeahead search with a count of 100. When the user types into the filtered Input.ChoiceSet, the search "invoke" request that's sent to the bot contains a top of 15 instead of the expected 100.

I checked both the C# and NodeJS examples for bot-type-ahead-search-adaptive-cards, but neither provides the optional count field in the Input.ChoiceSet (here for C# and here for NodeJS). They also both ignore the skip and top fields provided in the search "invoke" request that's triggered by the Input.ChoiceSets.

The count I'm referring to is in the Data.Query definition documented here, and the top is in the "invoke" request documented here.

sayali-MSFT commented 2 years ago

Could you please try with the Input.ChoiceSet with a property autoComplete that describes how to query the bot to dynamically retrieve values for the choice-set.- https://github.com/siduppal/general/blob/master/AutoComplete-Proposal.md

thomasylee commented 2 years ago

I've tried adding the autoComplete parameter a few different ways, but it does not seem to result in any request getting sent to the bot... the attribute appears to be ignored by Microsoft Teams.

That's probably expected since that link is for a new feature proposal that has not been marked as released yet, and its corresponding GitHub issue has been open for 2 years.

thomasylee commented 2 years ago

The documentation for the Data.Query definition states that count is a Number that "Populates for the invoke request to the bot to specify the number of elements that must be returned. The bot ignores it, if the users want to send a different amount."

That sounds exactly like the attribute that should be specifying the search request's top attribute (the number of results to search for) in the invoke request, no?

ChetanSharma-msft commented 2 years ago

Hello @thomasylee - Please let us know if you need any further help here or shall we close this issue?

thomasylee commented 2 years ago

Please let us know if you need any further help here or shall we close this issue?

@ChetanSharma-msft The bug still exists, so this issue needs to remain open. Please read the issue description and my other comments.

In summary: The documentation clearly states that the count attribute in Data.Query should influence the number of results sent to the invoke request (the top) attribute, but Microsoft Teams is not setting top to count like it should be. Instead, it always uses the default value of 15, incorrectly.

Please refer to my curl command or try updating the example code you sent me with count and top attributes to easily reproduce the problem.

ChetanSharma-msft commented 2 years ago

@thomasylee - Thanks for providing more details. We will investigate further and get back to you.

ghost commented 2 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 3 days. It will be closed if no further activity occurs within 3 days of this comment.

ghost commented 2 years ago

Hi Wajeed-msft! Thank you for bringing this issue to our attention. We will investigate and if we require further information we will reach out in one business day. Please use this link to escalate if you don't get replies.

Best regards, Teams Platform

ghost commented 2 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 3 days. It will be closed if no further activity occurs within 3 days of this comment.

thomasylee commented 2 years ago

Any updates on this? Or are there any additional details you need from me?

sayali-MSFT commented 2 years ago

Sorry for the delay, We are investigating the on this scenario, We will inform you once we get any update.

ghost commented 2 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 3 days. It will be closed if no further activity occurs within 3 days of this comment.

thomasylee commented 2 years ago

Could we remove the needs-author-feedback tag if no further details are needed from me at the moment?

thomasylee commented 2 years ago

Hi, any update on this issue? The count attribute in Data.Query is still getting ignored, resulting in top always being the default 15.

sayali-MSFT commented 2 years ago

@thomasylee -We are also able to repro the scenario, Checking with engineering team, it's Bydefault behaviour or Bug? If it is Bug then we will raise it accordingly.

thomasylee commented 2 years ago

@sayali-MSFT I'm not sure if your question was to me or the engineering team, but to me it appears to be a bug since the behavior does not match the documentation. The documentation makes sense, since count and top would be very valuable if they worked as documented, so it seems that the implementation is just not handling those attributes the way it should.

sayali-MSFT commented 2 years ago

@thomasylee - We have raised bug for the same and concerned team is looking into it. We will inform you once we get any update.

sayali-MSFT commented 1 year ago

@thomasylee -Sorry for delay in response!! We are actively checking the status of bug with engineering team and let you know the updates, if we have any.

deekshanya commented 1 year ago

@thomasylee Hi, I am from the dev team.. are you still facing this issue? I fixed the bug December 2022, and I have no repro. If you still face issues, can you send repro steps plus attach your bot for reference? Thanks

sayali-MSFT commented 1 year ago

@thomasylee -Did you get chance to check?

jvrasa commented 1 year ago

Hi I'm facing this issue too, in 2 different repo. Can't link the first one as it's for work but I also tried with the code sample provided in the doc and it doesn't work (this one).

Steps:

Search response

    "type": "application/vnd.microsoft.search.searchResponse",
    "value": {
        "results": [
            {
                "title": "js",
                "value": "js - A better `node -p`."
            },
            {
                "title": "core-js",
                "value": "core-js - Standard library"
            },
            {
                "title": "styled-components",
                "value": "styled-components - Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress"
            },
            {
                "title": "uglify-js",
                "value": "uglify-js - JavaScript parser, mangler/compressor and beautifier toolkit"
            },
            {
                "title": "libphonenumber-js",
                "value": "libphonenumber-js - A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript"
            },
            {
                "title": "js-yaml",
                "value": "js-yaml - YAML 1.2 parser and serializer"
            },
            {
                "title": "postcss",
                "value": "postcss - Tool for transforming styles with JS plugins"
            },
            {
                "title": "crypto-js",
                "value": "crypto-js - JavaScript library of crypto standards."
            },
            {
                "title": "js-cookie",
                "value": "js-cookie - A simple, lightweight JavaScript API for handling cookies"
            },
            {
                "title": "get-intrinsic",
                "value": "get-intrinsic - Get and robustly cache all JS language-level intrinsics at first require time"
            },
            {
                "title": "xml-js",
                "value": "xml-js - A convertor between XML text and Javascript object / JSON text."
            },
            {
                "title": "ua-parser-js",
                "value": "ua-parser-js - Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data. Supports browser & node.js environment"
            },
            {
                "title": "eslint-config-airbnb-base",
                "value": "eslint-config-airbnb-base - Airbnb's base JS ESLint config, following our styleguide"
            },
            {
                "title": "is-callable",
                "value": "is-callable - Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag."
            },
            {
                "title": "graphql",
                "value": "graphql - A Query Language and Runtime which can target any service."
            },
            {
                "title": "karma",
                "value": "karma - Spectacular Test Runner for JavaScript."
            },
            {
                "title": "serialize-javascript",
                "value": "serialize-javascript - Serialize JavaScript to a superset of JSON that includes regular expressions and functions."
            },
            {
                "title": "js-tokens",
                "value": "js-tokens - Tiny JavaScript tokenizer."
            },
            {
                "title": "is-array-buffer",
                "value": "is-array-buffer - Is this value a JS ArrayBuffer?"
            },
            {
                "title": "md5",
                "value": "md5 - js function for hashing messages with MD5"
            }
        ]
    }
}

In the bot

typeahead-top

typeaheaad-top-2

As you can see, I have 20 results but only 15 are shown. The invoke request completely ignores the count property set in Data.Query:

"value": {
        "queryText": "js",
        "queryOptions": {
            "skip": 0,
            "top": 15
        },
        "dataset": "npmpackages"
    },
deekshanya commented 1 year ago

@jvrasa did you happen to set the "count" property on here?

image
jvrasa commented 1 year ago

Yes I added "count": 50 in "choices.data". I forgot to include that step in the how-to above. typeahead

Also sorry I made a mistake, I had too many tabs opened when I wrote the reply yesterday. The invoke request doesn't ignore the count property, but the bot does.

sayali-MSFT commented 1 year ago

@jvrasa -Thanks for providing information, We will inform the engineering team and let you know the update.

deekshanya commented 1 year ago

@jvrasa to confirm, the invoke is returning the expected response, but the bot dropdown isn't showing the right number of results? Also, may I know if your bot is in a group chat or if it's a channel within a team?

jvrasa commented 1 year ago

@deekshanya yes that's right. The invoke is correct but the bot doesn't show all the options. I'm not sure what you mean, it's neither of that. It's a personal, one-to-one conversation bot.

sayali-MSFT commented 1 year ago

@deekshanya -Could you please help for the above ask?

deekshanya commented 1 year ago

@jvrasa we have a limit of how many options can be displayed by the dropdown. It's currently limited to 15 or lower. If we need that to be modified, let's track it another issue.

Since this issue is tracking if invoke is returning expected number of results, we should be good to close this issue. @sayali-MSFT

sayali-MSFT commented 1 year ago

We are closing this issue for now, please feel free to reopen it, if required.

ghost commented 1 year ago

Tell us about your experience!

Hi Wajeed-msft! This issue is closed in our system. We would like your feedback on your experience with our support team and Platform.

Best regards, Teams Platform

ghost commented 1 year ago

Hi Wajeed-msft! Thank you for bringing this issue to our attention. We will investigate and if we require further information we will reach out in one business day. Please use this link to escalate if you don't get replies.

Best regards, Teams Platform