This repository was archived by the owner on Jan 5, 2026. It is now read-only.
Repository navigation
Add support for search invoke #6272
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Newtonsoft.Json; | ||
|
|
||
| namespace Microsoft.Bot.Schema | ||
| { | ||
| /// <summary> | ||
| /// Defines the query options in the <see cref="SearchInvokeValue"/> for Invoke activity with Name of 'application/search'. | ||
| /// </summary> | ||
| public class SearchInvokeOptions | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the the starting reference number from which ordered search results should be returned. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The the starting reference number from which ordered search results should be returned. | ||
| /// </value> | ||
| [JsonProperty("skip")] | ||
| public int Skip { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the number of search results that should be returned. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The number of search results that should be returned. | ||
| /// </value> | ||
| [JsonProperty("top")] | ||
| public int Top { get; set; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Newtonsoft.Json; | ||
|
|
||
| namespace Microsoft.Bot.Schema | ||
| { | ||
| /// <summary> | ||
| /// Defines the structure that is returned as the result of an Invoke activity with Name of 'application/search'. | ||
| /// </summary> | ||
| public class SearchInvokeResponse : AdaptiveCardInvokeResponse | ||
| { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| namespace Microsoft.Bot.Schema | ||
| { | ||
| /// <summary> | ||
| /// Defines values for SearchInvokeTypes. See <see cref="SearchInvokeValue"/>. | ||
| /// </summary> | ||
| public static class SearchInvokeTypes | ||
| { | ||
| /// <summary> | ||
| /// The type for Search. | ||
| /// Implies a standard, paginated search operation that expects | ||
| /// one or more templated results to be returned. | ||
| /// </summary> | ||
| public const string Search = "search"; | ||
|
|
||
| /// <summary> | ||
| /// The type for bot SearchAnswer. | ||
| /// Implies a simpler search that does not include pagination, | ||
| /// and most typically only returns a single search result. | ||
| /// </summary> | ||
| public const string SearchAnswer = "searchAnswer"; | ||
|
|
||
| /// <summary> | ||
| /// The type for Typeahead. | ||
| /// Implies a search for a small set of values, most often used | ||
| /// for dynamic auto-complete or type-ahead UI controls. | ||
| /// This search supports pagination. | ||
| /// </summary> | ||
| public const string Typeahead = "typeahead"; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Newtonsoft.Json; | ||
|
|
||
| namespace Microsoft.Bot.Schema | ||
| { | ||
| /// <summary> | ||
| /// Defines the structure that arrives in the Activity.Value for Invoke activity | ||
| /// with Name of 'application/search'. | ||
| /// </summary> | ||
| public class SearchInvokeValue | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the kind for the search invoke value. | ||
| /// Must be either search, searchAnswer, or typeahead. | ||
| /// <see cref="SearchInvokeTypes"/>. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The kind for this search invoke action value. | ||
| /// </value> | ||
| [JsonProperty("kind")] | ||
| public string Kind { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the query text for the search invoke value. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The query text of this search invoke action value. | ||
| /// </value> | ||
| [JsonProperty("queryText")] | ||
| public string QueryText { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the <see cref="SearchInvokeOptions"/> for this search invoke. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The <see cref="SearchInvokeOptions"/> for this search invoke. | ||
| /// </value> | ||
| [JsonProperty("queryOptions")] | ||
| public SearchInvokeOptions QueryOptions { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the context information about the query. Such as the UI | ||
| /// control that issued the query. The type of the context field is object | ||
| /// and is dependent on the kind field. For search and searchAnswers, | ||
| /// there is no defined context value. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The context information about the query. | ||
| /// </value> | ||
| [JsonProperty("context")] | ||
| public object Context { get; set; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Xunit; | ||
|
|
||
| namespace Microsoft.Bot.Schema.Tests | ||
| { | ||
| public class SearchQueryTests | ||
| { | ||
| [Fact] | ||
| public void SearchInvokeValue() | ||
| { | ||
| var kind = SearchInvokeTypes.Typeahead; | ||
| var context = "Microsoft.Graph"; | ||
| var options = new SearchInvokeOptions { Skip = 10, Top = 5 }; | ||
| var text = "the query text"; | ||
|
|
||
| var value = new SearchInvokeValue() | ||
| { | ||
| Kind = kind, | ||
| Context = context, | ||
| QueryOptions = options, | ||
| QueryText = text | ||
| }; | ||
|
|
||
| Assert.Equal(kind, value.Kind); | ||
| Assert.Equal(context, value.Context); | ||
| Assert.Equal(options, value.QueryOptions); | ||
| Assert.Equal(text, value.QueryText); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void SearchInvokeResponse() | ||
| { | ||
| var statusCode = 200; | ||
| var type = "myType"; | ||
| var value = new { }; | ||
|
|
||
| var res = new SearchInvokeResponse() | ||
| { | ||
| StatusCode = statusCode, | ||
| Type = type, | ||
| Value = value, | ||
| }; | ||
|
|
||
| Assert.Equal(statusCode, res.StatusCode); | ||
| Assert.Equal(type, res.Type); | ||
| Assert.Equal(value, res.Value); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void SearchQueryOptions() | ||
| { | ||
| int skip = 10; | ||
| int top = 5; | ||
|
|
||
| var options = new SearchInvokeOptions | ||
| { | ||
| Skip = skip, | ||
| Top = top | ||
| }; | ||
|
|
||
| Assert.Equal(skip, options.Skip); | ||
| Assert.Equal(top, options.Top); | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: isn't nameof going to give you the C# identifier whereas what you really want in the error message is the JSON property name. OK this is perhaps a nit because the only difference in this case at the current time is the casing.
I'm assuming the json property attribute doesn't override the nameof result (can you even do that?)