Skip to main content

Combined YAML

Botium test cases can be composed in YAML format. However, they are not standalone. This means that they are not confined to one utterance, or one convo per file. One YAML can contain more convos/utterances, that is why they are 'combined'.

YAML Structure

YAML files are structured using indentation to indicate hierarchy and relationships between elements. Here, we will break down the components of a YAML file used for defining conversations in a bot.

Conversations

The convos section defines a list of conversations, each with a name, description, and steps that detail the interaction between the user (me) and the bot.

convos:
  - name: goodbye
    description: desc of convo goodbye
    steps:
      - begin:
          - PAUSE 500
      - me:
          - bye
      - bot:
          - goodbye!
  - name: convo 1 name
    description: desc of convo
    steps:
      - me:
          - GREETING
          - PAUSE:
            - 500
      - bot:
          - NOT_TEXT:
            - hello
          - INTENT:
            - intent_greeting
      - bot:
          - what can i do for you?
      - me:
          - nothing
      - bot:
          - thanks

Explanation:

  • convos: List of conversations.
  • name: Unique identifier for the conversation.
  • description: Brief description of the conversation.
  • steps: Sequence of interactions within the conversation.
    • begin: Initial action, such as a pause.
    • me: User's input.
    • bot: Bot's response.

Utterances

The utterances section defines common phrases that the bot can recognize and respond to.
utterances:
  GREETING:
    - hi
    - hello!

Explanation:

  • utterances: Dictionary of keywords or phrases.
  • GREETING: List of greetings that the bot can recognize.

Scripting Memory

The scriptingMemory section defines variables that can be used across different scenarios.
scriptingMemory:
  - header:
      name: scenario1
    values:
      $var1: var1_1
      $var2: var2_1
  - header:
      name: scenario2
    values:
      $var1: var1_2
      $var2: var2_2
Explanation:
  • scriptingMemory: List of memory headers and values.
  • header: Name of the scenario.
  • values: Key-value pairs of variables.
Tip: For more information on scripting memory read the article Using the Scripting Memory.

Special Syntax

To denote specific types of content or assertions, certain syntax rules are used:

  • Starting !: Indicates a special notation, such as a quoted string to negate assertions.
  • Nested Assertions: Prefixed with NOT_ instead of using ! due to YAML's syntax rules.
    convos:
      - name: quote
        steps:
          - me:
              - Hello!
          - bot:
              - "!TEXT_CONTAINS_ANY goodbye, bye"
    

Explanation:

  • Quoted Assertions: "!TEXT_CONTAINS_ANY goodbye, bye" ensures the bot checks for any of the listed words.
  • Nested Assertions: Avoid using ! for nested objects, use NOT_ prefix instead.

Example Code

Here's a full example putting all the pieces together:
convos:
  - name: goodbye
    description: desc of convo goodbye
    steps:
      - begin:
          - PAUSE 500
      - me:
          - bye
      - bot:
          - goodbye!
  - name: convo 1 name
    description: desc of convo
    steps:
      - me:
          - GREETING
          - PAUSE:
            - 500
      - bot:
          - NOT_TEXT:
            - hello
          - INTENT:
            - intent_greeting
      - bot:
          - what can i do for you?
      - me:
          - nothing
      - bot:
          - thanks
utterances:
  GREETING:
    - hi
    - hello!
scriptingMemory:
  - header:
      name: scenario1
    values:
      $var1: var1_1
      $var2: var2_1
  - header:
      name: scenario2
    values:
      $var1: var1_2
      $var2: var2_2
convos:
  - name: quote
    steps:
      - me:
          - Hello!
      - bot:
          - "!TEXT_CONTAINS_ANY goodbye, bye"

This example demonstrates how to structure a YAML file for bot conversations, including defining steps, utterances, and scripting memory with clear and easy-to-follow syntax.

Was this article helpful?

0 out of 0 found this helpful