# Name: Knowledge Search
# Template: Generative answers from knowledge sources (fallback search)
# NOTE: Replace all _REPLACE IDs with unique random IDs before use
kind: AdaptiveDialog
beginDialog:
  kind: OnUnknownIntent
  id: main
  priority: -1
  actions:
    # Step 1: Generate an optimized search query that preserves conversational context
    - kind: CreateSearchQuery
      id: createSearchQuery_REPLACE1
      userInput: =System.Activity.Text
      result: Topic.SearchQuery

    # Step 2: Search all agent knowledge sources with the optimized query
    - kind: SearchAndSummarizeContent
      id: searchContent_REPLACE2
      variable: Topic.Answer
      userInput: =Topic.SearchQuery.SearchQuery

    - kind: ConditionGroup
      id: conditionGroup_REPLACE3
      conditions:
        - id: conditionItem_REPLACE4
          condition: =!IsBlank(Topic.Answer)
          actions:
            - kind: EndDialog
              id: endDialog_REPLACE5
              clearTopicQueue: true
