title: Message Automation Step Input
type: object
x-tags:
  - Models
description: A message step with a condition evaluated once from the incoming message's first/repeat status.
required:
  - send_when
  - body
additionalProperties: false
properties:
  send_when:
    type: string
    enum:
      - always
      - first_match
      - repeat_match
    description: Always send, send only on the sender's first matching message within interaction_scope, or send
      only on subsequent matches in that scope. History spans all trigger phrases and includes failed replies.
    example: first_match
  interaction_scope:
    type: string
    enum:
      - automation
      - merchant
    default: automation
    description: History used by first_match and repeat_match. automation uses this automation; merchant uses all
      matching messages for the same merchant and sender phone across outlets, including automations configured
      with either scope. Existing history is retained when scope changes. Has no effect on always steps.
    example: merchant
  body:
    type: object
    description: "One immediate WhatsApp message. Placeholders are permitted only in text and must appear in the
      automation’s supported_params. Text headers require a URL action. Image/video captions and URL-button
      messages use the shorter text limit below. Media must belong to the merchant: JPEG/PNG images up to 5 MiB,
      or MP4 videos up to 16 MiB with H.264 video and optional AAC audio. Submitted WhatsApp templates, quick
      replies and bot actions are not used for these steps."
    required:
      - text
      - header
      - action
    additionalProperties: false
    properties:
      text:
        type: string
        minLength: 1
        maxLength: 4096
        description: Message text with supported merchant and incoming-sender placeholders and constrained Markdown formatting.
        example: Hi {{sender_profile_name}}, welcome to {{merchant_name}}. Here is our menu.
      header:
        oneOf:
          - type: "null"
          - allOf:
              - $ref: ./MessageTemplateTextHeader.yaml
              - properties:
                  text:
                    maxLength: 60
          - $ref: ./MessageTemplateImageHeaderInput.yaml
          - $ref: ./MessageTemplateVideoHeaderInput.yaml
      action:
        oneOf:
          - type: "null"
          - $ref: ./MessageAutomationUrlAction.yaml
    allOf:
      - if:
          anyOf:
            - properties:
                action:
                  type: object
              required:
                - action
            - properties:
                header:
                  type: object
                  properties:
                    type:
                      enum:
                        - image
                        - video
                  required:
                    - type
              required:
                - header
        then:
          properties:
            text:
              maxLength: 1024
      - if:
          properties:
            header:
              type: object
              properties:
                type:
                  const: text
              required:
                - type
          required:
            - header
        then:
          properties:
            action:
              type: object
