<!--
{
  "availability" : [
    "iOS: 27.3.0 -",
    "iPadOS: 27.3.0 -",
    "macOS: 27.3.0 -",
    "visionOS: 27.3.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SiriEvaluations",
  "identifier" : "/documentation/SiriEvaluations/SiriScenario",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Siri Evaluations"
    ],
    "preciseIdentifier" : "s:15SiriEvaluations0A8ScenarioV"
  },
  "title" : "SiriScenario"
}
-->

# SiriScenario

An ordered, multiturn interaction run in one Siri session.

```
struct SiriScenario
```

## Overview

A *scenario* is a conversation made of a sequence of turns. Each turn is something
a person says, and Siri handles the turns in one session in the order you write
them. A turn carries its own expectations about what Siri does, and the scenario
carries expectations about the whole conversation.

A turn’s expectations apply only to that turn. A scenario’s expectations apply
to all of its turns together. Put an expectation on the scenario when it spans
turns, such as an intent that finishes only after the person answers a question.
Using a [`Calls`](/documentation/SiriEvaluations/Calls) structure’s expectation on the scenario with
[`Calls.Ordering.disallowed`](/documentation/SiriEvaluations/Calls/Ordering-swift.enum/disallowed) fails if the call runs in any turn, or if Siri
asks the person to confirm it in any turn. Use [`Calls.Ordering.unordered`](/documentation/SiriEvaluations/Calls/Ordering-swift.enum/unordered) when
each call happens in at least one turn, in any order.

A scenario conforms to
<doc://com.apple.documentation/documentation/Swift/Codable>, so you can encode
a set of scenarios as JSON to review alongside your project.

The following example shows a two-turn scenario with expectations that apply to
the whole conversation:

```swift
let quizExampleIntents = IntentDefinitions(bundleIdentifier: "com.example.QuizExample")
let startQuizIntent = quizExampleIntents.intents["StartQuizIntent"]
let createQuizReminderIntent = quizExampleIntents.intents["CreateQuizReminderIntent"]

let scenario = SiriScenario {
    // In turn one, the person names the app but not the topic, so Siri
    // asks for one.
    UserTurn("Start a quiz in QuizExample")

    // The second turn answers with a topic.
    UserTurn("Science")
} expectation: {
    Calls {
        // The topic label comes from the parameter on the intent.
        startQuizIntent
            .expect(topic: .equals("Science"))
    }

    // Fails if Siri runs or asks the person to confirm the intent in any turn.
    Calls(.disallowed) {
        createQuizReminderIntent
    }
}
```

To run a scenario through Siri, pass it to a [`SiriScenarioLoader`](/documentation/SiriEvaluations/SiriScenarioLoader) to make it
part of the dataset for an evaluation that runs with [`SiriService`](/documentation/SiriEvaluations/SiriService).

## Topics

### Creating a scenario

[`init(() -> [UserTurn])`](/documentation/SiriEvaluations/SiriScenario/init(_:))

The turns of the conversation, in order.

[`enum SiriScenarioBuilder`](/documentation/SiriEvaluations/SiriScenarioBuilder)

A result builder that collects the turns of a scenario.

### Creating a scenario with expectations

[`init(() -> [UserTurn], expectation: () -> SiriScenarioExpectationBuilder.Component)`](/documentation/SiriEvaluations/SiriScenario/init(_:expectation:))

Creates a scenario from its turns, plus expectations for the conversation as a whole.

[`enum SiriScenarioExpectationBuilder`](/documentation/SiriEvaluations/SiriScenarioExpectationBuilder)

A result builder that collects the expectations you attach to a scenario.

### Inspecting a scenario

[`let turns: [UserTurn]`](/documentation/SiriEvaluations/SiriScenario/turns)

The turns of the conversation in the order that the person says them.

[`var input: String`](/documentation/SiriEvaluations/SiriScenario/input)

The scenario’s utterances joined into one line for the report’s Input column.

[`var expected: SiriScenarioSubject.ScenarioReport?`](/documentation/SiriEvaluations/SiriScenario/expected)

The scenario’s expectations as the report’s Expected column.

### Encoding a scenario

[`func encode(to: any Encoder) throws`](/documentation/SiriEvaluations/SiriScenario/encode(to:))

The scenario’s own fields, plus the utterances as one line.

## Relationships

### Conforms To

[`Decodable`](/documentation/Swift/Decodable)

[`SampleProtocol`](/documentation/Evaluations/SampleProtocol)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Encodable`](/documentation/Swift/Encodable)

[`Sendable`](/documentation/Swift/Sendable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)