{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/shortsync-app/json-schema/shortsync-app-comment-dm-rule-schema.json",
  "title": "CommentDmRule",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/shortsync-app-openapi.yml#/components/schemas/CommentDmRule",
  "type": "object",
  "required": [
    "id",
    "keywords",
    "messages",
    "message",
    "message_mode",
    "enabled",
    "disclosure_missing"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "connection_id": {
      "type": "string",
      "format": "uuid"
    },
    "platform": {
      "type": "string",
      "enum": [
        "instagram",
        "facebook"
      ]
    },
    "triggers": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "comment",
          "story_reply",
          "dm_keyword",
          "live_comment",
          "story_mention"
        ]
      },
      "description": "Everything that starts the rule."
    },
    "media": {
      "type": "array",
      "description": "The posts its `comment` trigger is limited to. Empty means every post.",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "caption": {
            "type": [
              "string",
              "null"
            ]
          },
          "thumbnail_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "permalink": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    },
    "trigger": {
      "type": "string",
      "enum": [
        "comment",
        "story_reply",
        "dm_keyword",
        "live_comment",
        "story_mention"
      ],
      "description": "The first of `triggers`, for callers from before several."
    },
    "media_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "The first of `media`, for callers from before several. Null means every post."
    },
    "media_caption": {
      "type": [
        "string",
        "null"
      ]
    },
    "media_thumbnail_url": {
      "type": [
        "string",
        "null"
      ]
    },
    "media_permalink": {
      "type": [
        "string",
        "null"
      ]
    },
    "keywords": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "messages": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "message": {
      "type": "string",
      "description": "The first version, for callers from before versions."
    },
    "message_mode": {
      "type": "string",
      "enum": [
        "variants",
        "ai"
      ]
    },
    "ai_brief": {
      "type": [
        "string",
        "null"
      ]
    },
    "link": {
      "type": [
        "string",
        "null"
      ]
    },
    "public_reply_enabled": {
      "type": "boolean"
    },
    "public_replies": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "track_clicks": {
      "type": "boolean"
    },
    "delivery": {
      "type": "string",
      "enum": [
        "text",
        "button",
        "card"
      ]
    },
    "button_label": {
      "type": [
        "string",
        "null"
      ]
    },
    "card_title": {
      "type": [
        "string",
        "null"
      ]
    },
    "card_subtitle": {
      "type": [
        "string",
        "null"
      ]
    },
    "card_image_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "The card image, a link that works for 24 hours."
    },
    "gate": {
      "type": "string",
      "enum": [
        "none",
        "follow",
        "email",
        "follow_email"
      ]
    },
    "gate_button_label": {
      "type": [
        "string",
        "null"
      ]
    },
    "reply_word": {
      "type": [
        "string",
        "null"
      ]
    },
    "follow_prompt": {
      "type": [
        "string",
        "null"
      ]
    },
    "email_prompt": {
      "type": [
        "string",
        "null"
      ]
    },
    "delivery_message": {
      "type": [
        "string",
        "null"
      ]
    },
    "delivery_messages": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "delivery_message_mode": {
      "type": "string",
      "enum": [
        "variants",
        "ai"
      ]
    },
    "delivery_ai_brief": {
      "type": [
        "string",
        "null"
      ]
    },
    "question_text": {
      "type": [
        "string",
        "null"
      ]
    },
    "question_options": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "link": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    },
    "insights": {
      "type": [
        "object",
        "null"
      ],
      "description": "The last 7 days of events and the rule's funnel.",
      "properties": {
        "seen_7d": {
          "type": "integer",
          "description": "Events the rule listened to (comments on its posts",
          "DMs": null,
          "story replies or mentions).": null
        },
        "matched_7d": {
          "type": "integer",
          "description": "Of those",
          "the ones with a keyword.": null
        },
        "funnel": {
          "type": [
            "object",
            "null"
          ],
          "description": "Rules with a tap step. First DMs, taps, follows, emails, answers, links sent and clicks.",
          "properties": {
            "started": {
              "type": "integer"
            },
            "tapped": {
              "type": "integer"
            },
            "followed": {
              "type": "integer"
            },
            "emailed": {
              "type": "integer"
            },
            "answered": {
              "type": "integer"
            },
            "delivered": {
              "type": "integer"
            },
            "clicked": {
              "type": "integer"
            }
          }
        },
        "delivery_stats": {
          "type": "object",
          "description": "Sent and clicked per version of the message with the link (`index` in `delivery_messages`), and for AI-written ones."
        },
        "answer_stats": {
          "type": "array",
          "description": "How many picked each answer (`index` in `question_options`) and clicked.",
          "items": {
            "type": "object",
            "properties": {
              "index": {
                "type": "integer"
              },
              "count": {
                "type": "integer"
              },
              "clicked": {
                "type": "integer"
              }
            }
          }
        }
      }
    },
    "attachments": {
      "type": "array",
      "description": "Files sent after the link (added in ShortSync).",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "image",
              "file"
            ]
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "followup_enabled": {
      "type": "boolean"
    },
    "followup_max": {
      "type": "integer"
    },
    "contact_count": {
      "type": "integer",
      "description": "Emails this rule collected."
    },
    "video_post_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Set when the rule was made with a post (`instagram.comment_dm`); it started when the post went live."
    },
    "enabled": {
      "type": "boolean"
    },
    "disclosure_missing": {
      "type": "boolean",
      "description": "True when the message doesn't say it's automated."
    },
    "last_error": {
      "type": [
        "string",
        "null"
      ],
      "description": "The latest problem sending. Clears after the next DM goes out."
    },
    "last_error_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "last_sent_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "sent_count": {
      "type": "integer"
    },
    "failed_count": {
      "type": "integer",
      "description": "Refused by Instagram, or not confirmed. Unconfirmed DMs are never sent again."
    },
    "queued_count": {
      "type": "integer"
    },
    "clicked_count": {
      "type": "integer",
      "description": "Sent DMs whose link was opened at least once (with `track_clicks`)."
    },
    "variant_stats": {
      "type": "array",
      "description": "Per version of `messages`, in order.",
      "items": {
        "type": "object",
        "properties": {
          "sent": {
            "type": "integer"
          },
          "clicked": {
            "type": "integer"
          }
        }
      }
    },
    "ai_stats": {
      "type": [
        "object",
        "null"
      ],
      "description": "AI-written DMs, in `ai` mode.",
      "properties": {
        "sent": {
          "type": "integer"
        },
        "clicked": {
          "type": "integer"
        }
      }
    }
  }
}