Search code examples
botframeworkmicrosoft-teams

MS Teams and Bot Framework - How can we paginate the result of query type messaging extension?


For searching through messaging extensions, there is a huge list of items for my query. For initialRun of the query, I am getting

queryOptions: {
    skip: 0,
    count:25
}

So, my questions are,

  1. Can I manipulate these queryOptions for initialRun?
  2. Can I update these queryOptions with each search response of messaging extension?
  3. If #1 and #2 are not possible then is there any way through which I may achieve behavior like lazy loading items onScroll of the messaging extension result?
  4. Are there any other alternatives for paginating the result data in messaging extension?

Solution

    • For question 1 and 2: We cannot manipulate queryOptions for such scenarios.
    • For question 3: Messaging extension doesn't have onScroll or any such property and that cannot be done.
    • For question 4: You can handle it in your code manually and set how many items you want to show initially and how many when you search something. When messaging extension is run initially, query parameter name is set to "initialRun". So you can handle it using parameters name.

    EDIT: Adding code snippet for reference :

    if (query.Parameters[0].Name == "initialRun")
    {
        // Write the code handling number of results to be return.
    }
    else
    {
        // Write the code handling number of results to be return when user search.
    }