Share via


Create search query

The Create search query action lets makers capture a rewritten version of a user's input—often enriched with conversation history—before using it in downstream tasks, such as search or summarization. This rewritten string gives makers a structured and clarified version of the original query, which they can repurpose to fit their custom logic.

This functionality is especially powerful for custom search scenarios. The maker can take full control over how queries are matched to indexed content, passed to external systems, or logged for analytics.

As copilots evolve from simple Q&A bots to tailored business agents, reshaping user queries becomes essential. Query rewriting bridges the gap between user intent and domain-specific language to enable more relevant and accurate results.

When to use Create search query

Use Create search query when you want to perform the following actions:

Drive custom search experiences

Use the rewritten query string as an input for your own search logic. Examples include querying a non-Microsoft API, filtering internal knowledge bases, or crafting dynamic prompts.

Example: Feed the rewritten query into a custom SharePoint or SQL-based search system.

Enhance relevance with context

Use conversation history to rewrite vague queries into something more targeted.

Example: Turn "show me the form" into "employee onboarding request form" based on previous user questions.

Power domain-specific retrieval

Tailor the rewritten query to match how your organization categorizes or indexes information.

Example: Add tags like department, timeframe, or user role to make search queries more precise.

How Create search query works

The Create search query dialog is accessed by adding a node in a topic, and selecting Add an action, then Create search query.

Screenshot of the authoring canvas, after a node was added, highlighting the Add an action selection and focused on Create search query.

The Create search query action rewrites the user’s input using:

  • The original input

  • Any relevant conversation history or context variables

The output, a cleaned and enriched search string, is returned as a variable for use in downstream logic.

Screenshot of the Create search query dialog.

It’s not just for the built-in copilot search; it’s for any custom behavior you want to enable.

Use case example: employee handbook copilot

A user might say: "Tell me about the leave policy."

The agent enriches this request with:

  1. The type of leave

  2. Whether the leave is for themselves or someone else

  3. Whether they want the current policy or a historical policy

Dialog flow (simplified YAML representation)

# Compose the custom search input

- kind: SetVariable 

  variable: Topic.SearchQueryInput 

  value: = "Leave policy: " & PlainText(Topic.LeaveType) &  

           If(Topic.ForSelf, "; for self", "; for someone else") &  

           "; version: " & PlainText(Topic.IsCurrentPolicy) &  

           "; original query: " & PlainText(Topic.UserOriginalInput)

# Generate a rewritten query using CreateSearchQuery 

- kind: CreateSearchQuery 

  userInput: =Topic.SearchQueryInput 

  result: Topic.SearchQuery 

# Use it in any way you want 

- kind: CustomSearchOrAPI 

  input: =Topic.SearchQuery 

Final rewritten query example

Leave policy: sick; for self; version: current; original query: I want to know about sick leave

This rewritten string can now be:

  • Passed into a custom search engine.

  • Used in an external API call.

  • Logged for analytics or tuning.

  • Displayed back to the user for confirmation.