{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/shortsync-app/json-schema/shortsync-app-comment-dm-rule-input-schema.json",
  "title": "CommentDmRuleInput",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/shortsync-app-openapi.yml#/components/schemas/CommentDmRuleInput",
  "type": "object",
  "properties": {
    "platform": {
      "type": "string",
      "enum": [
        "instagram",
        "facebook"
      ],
      "default": "instagram",
      "description": "Set on create. `facebook`: the workspace's connected Facebook Page\n(reconnect it once for the `pages_manage_metadata` permission).\nFacebook rules start from post comments or Messenger DMs and skip\nthe follow check; `post_id` is a Facebook post id (`pageid_postid`).\n"
    },
    "triggers": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "enum": [
          "comment",
          "story_reply",
          "dm_keyword",
          "live_comment",
          "story_mention"
        ]
      },
      "description": "Everything that starts the rule, one or more, for example\n`[comment, story_reply]`. Use instead of `trigger`. Each person\nstill gets the rule's DM once. `story_mention`: someone mentions\nthe account in their story; it needs no keyword. Facebook rules:\n`comment` and `dm_keyword`.\n"
    },
    "trigger": {
      "type": "string",
      "enum": [
        "comment",
        "story_reply",
        "dm_keyword",
        "live_comment",
        "story_mention"
      ],
      "default": "comment",
      "description": "One trigger, the shape from before `triggers` (ignored when\n`triggers` is set). What starts the rule. `comment`: a comment on a post (`post_id`\npicks one). `story_reply`: a reply to any of the account's\nstories. `dm_keyword`: a DM to the account that isn't part of\nanother automation. `live_comment`: a comment during a Live,\nanswered while it's on. Each person gets the rule's DM once.\nPublic replies are for comment rules only.\n"
    },
    "keywords": {
      "type": "array",
      "maxItems": 20,
      "items": {
        "type": "string",
        "maxLength": 50
      },
      "description": "Whole words, any case. Emoji work too. Can be empty only when `story_mention` is the rule's only trigger."
    },
    "messages": {
      "type": "array",
      "minItems": 1,
      "maxItems": 5,
      "items": {
        "type": "string"
      },
      "description": "Versions of the DM; each person gets one picked at random. Up to\n1,000 bytes each with placeholders filled in: `{first_name}` (first\nname on Facebook, @name on Instagram), `{username}` (the\ncommenter as @name), `{keyword}` (the keyword they matched),\n`{link}` (the rule's link). In `ai` mode, the fallback sent when\nthe AI can't write one or the month's AI DMs are used up.\n"
    },
    "message": {
      "type": "string",
      "description": "One DM text, the shape from before versions. Setting it replaces\nall versions. Include a line saying it's automated; some places,\nlike California and Germany, require it.\n"
    },
    "message_mode": {
      "type": "string",
      "enum": [
        "variants",
        "ai"
      ],
      "default": "variants",
      "description": "`ai`: AI writes each DM from `ai_brief`, greets the person and\nanswers their comment in their language, never adds links or\nclaims you didn't give, and ends with an automated-message line.\nCounts toward the organization's monthly AI DMs.\n"
    },
    "ai_brief": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 500,
      "description": "What the DM should say. Required in `ai` mode."
    },
    "link": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 500,
      "description": "Fills `{link}` and goes under every AI-written DM. `https://` is added when missing."
    },
    "public_reply_enabled": {
      "type": "boolean",
      "description": "Also post a short public reply under the comment."
    },
    "public_replies": {
      "type": "array",
      "maxItems": 5,
      "items": {
        "type": "string",
        "maxLength": 300
      },
      "description": "Each comment gets one. `{username}` and `{keyword}` work here."
    },
    "track_clicks": {
      "type": "boolean",
      "default": true,
      "description": "Send the link through a `https://www.shortsync.app/l/` short link\nso clicks are counted (`clicked_count`, `variant_stats`,\n`ai_stats`).\n"
    },
    "delivery": {
      "type": "string",
      "enum": [
        "text",
        "button",
        "card"
      ],
      "default": "text",
      "description": "How the link is sent. `text`: inside the message. `button`: the\nmessage (up to 640 characters, `{link}` left out) with a link\nbutton. `card`: a card with `card_title`, `card_subtitle` and a\nlink button (image cards are set up in ShortSync). Button and card\nneed a `link`. If Instagram doesn't accept a button or card in a\nreply to a comment, the message goes out as text with the link.\n"
    },
    "button_label": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 20,
      "description": "Button text for `button` and `card`. Defaults to \"Open link\"."
    },
    "card_title": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 80,
      "description": "Required for `card`."
    },
    "card_subtitle": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 80
    },
    "gate": {
      "type": "string",
      "enum": [
        "none",
        "follow",
        "email",
        "follow_email"
      ],
      "default": "none",
      "description": "A step before the link. `follow` checks they follow the account\n(after 3 tries the link goes out anyway). `email` asks for their\nemail and saves it to the contacts (`GET /comment-dms/contacts`).\nWith a step or `attachments`, the first DM ends with a button\n(`gate_button_label`); tapping it starts the next step, because\nInstagram allows one DM per comment until the person answers.\n"
    },
    "gate_button_label": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 20,
      "description": "Default \"Send me the link\"."
    },
    "reply_word": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 30,
      "description": "If Instagram refuses the button: \"Reply <word> and I'll send it\". Default YES."
    },
    "follow_prompt": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 640
    },
    "email_prompt": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 640
    },
    "delivery_message": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 640,
      "description": "One message sent with the link after the tap. Ignored when `delivery_messages` is set."
    },
    "delivery_messages": {
      "type": "array",
      "maxItems": 5,
      "items": {
        "type": "string",
        "maxLength": 640
      },
      "description": "Versions of the message sent with the link after the tap; one is\npicked at random. `{username}`, `{first_name}`, `{keyword}` and\n`{link}` are filled in. Empty: \"Here you go!\".\n"
    },
    "delivery_message_mode": {
      "type": "string",
      "enum": [
        "variants",
        "ai"
      ],
      "description": "`ai`: AI writes the message from `delivery_ai_brief`, with `delivery_messages` as the backup."
    },
    "delivery_ai_brief": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 500,
      "description": "What the AI-written message with the link says. Required in `ai` mode."
    },
    "question_text": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 640,
      "description": "A question asked after the follow and email steps, before the\nlink, with `question_options` as tap buttons. They can also reply\nwith an answer or its number; after two unclear replies the\nrule's link goes out. null removes it.\n"
    },
    "question_options": {
      "type": "array",
      "minItems": 2,
      "maxItems": 3,
      "items": {
        "type": "object",
        "required": [
          "label"
        ],
        "properties": {
          "label": {
            "type": "string",
            "maxLength": 20
          },
          "link": {
            "type": [
              "string",
              "null"
            ],
            "description": "The link this answer sends. null: the rule's link."
          }
        }
      }
    },
    "followup_enabled": {
      "type": "boolean",
      "description": "AI answers their replies for 24 hours after the link, from\n`ai_brief` (required). Stops when someone replies from the inbox,\nthe person asks for a human, or after `followup_max` answers.\n"
    },
    "followup_max": {
      "type": "integer",
      "minimum": 1,
      "maximum": 10,
      "default": 3
    },
    "ai_faqs": {
      "type": "array",
      "maxItems": 20,
      "description": "Questions and answers the AI follows closely when it answers\nreplies (`followup_enabled`). Replaces the list.\n",
      "items": {
        "type": "object",
        "required": [
          "question",
          "answer"
        ],
        "properties": {
          "question": {
            "type": "string",
            "maxLength": 200
          },
          "answer": {
            "type": "string",
            "maxLength": 1000
          }
        }
      }
    },
    "ai_source_urls": {
      "type": "array",
      "maxItems": 3,
      "items": {
        "type": "string"
      },
      "description": "Web pages (for example a pricing or FAQ page) the AI answers\nreplies from. ShortSync reads them when the rule is saved and\nagain when the text is a day old. Replaces the list.\n"
    },
    "post_ids": {
      "type": [
        "array",
        "null"
      ],
      "maxItems": 50,
      "items": {
        "type": "string"
      },
      "description": "Instagram post ids from `/comment-dms/posts`: the `comment`\ntrigger only answers comments on these posts. Null or `[]` watches\nevery post; left out keeps them (every post on create). Story\nreplies, DMs and Live comments aren't limited by it.\n"
    },
    "post_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "One post, the shape from before `post_ids` (ignored when `post_ids` is set). Null watches every post."
    },
    "enabled": {
      "type": "boolean",
      "default": true
    }
  }
}