{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/rizamo-com/json-schema/rizamo-com-comment-automation-schema.json",
  "title": "CommentAutomation",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/rizamo-com-openapi.json#/components/schemas/CommentAutomation",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "profileId": {
      "type": "string"
    },
    "accountId": {
      "type": "string"
    },
    "network": {
      "$ref": "#/$defs/Network"
    },
    "name": {
      "type": "string"
    },
    "status": {
      "enum": [
        "active",
        "paused"
      ],
      "type": "string",
      "description": "Paused: comments are not answered, and those that arrive meanwhile never will be."
    },
    "pausedReason": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Why Rizamo paused it, such as a permission Meta refused or a link of the message that stopped working: fix it, then resume. Null when it is active or someone paused it."
    },
    "networkPostId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Only comments on this post on the network (`List posts on the networks`). Null with `postId` null: every post of the account, new ones too."
    },
    "postId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Only comments on this Rizamo post, on the account: it can be scheduled, and the automation starts when it goes live there."
    },
    "armed": {
      "type": "boolean",
      "description": "False while its Rizamo post is not live on the account yet."
    },
    "keywords": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Any of them triggers it. Empty: every comment."
    },
    "match": {
      "enum": [
        "contains",
        "word",
        "exact"
      ],
      "type": "string",
      "description": "contains: the keyword anywhere, even inside a longer word. word (the default): as a whole word or phrase. exact: the whole comment is the keyword, give or take punctuation and spaces. Always in any case and with or without accents."
    },
    "exclude": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "A comment with any of these, as whole words, never triggers it."
    },
    "message": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string",
          "minLength": 1,
          "maxLength": 5000,
          "description": "With a link, up to 640 characters, above the button. Without, up to 1,000 bytes: Meta counts bytes, and accents and emoji take 2 to 4. Every web address in it becomes a Rizamo link that counts clicks, and counts as one (38 characters)."
        },
        "link": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 2048,
              "format": "uri"
            },
            {
              "type": "null"
            }
          ],
          "description": "Behind a button under the text, as a Rizamo link that counts clicks. Null for none: the message is the text alone."
        },
        "button": {
          "type": "string",
          "minLength": 1,
          "maxLength": 20,
          "description": "The button's title, up to 20 characters, such as \"Get the guide\". Left out: Open link on a new automation, the title it had on an update. Shown only with a link."
        }
      },
      "required": [
        "text",
        "link"
      ]
    },
    "links": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "The address as written in the message, without the UTM tags."
          },
          "shortUrl": {
            "type": "string",
            "description": "What the message carries instead. The address itself until Rizamo counts clicks on it."
          },
          "linkId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "The Rizamo link. Null while clicks are not counted."
          }
        },
        "required": [
          "url",
          "shortUrl",
          "linkId"
        ]
      },
      "description": "The Rizamo links in the message, one per web address."
    },
    "utm": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "source": {
              "type": "string",
              "maxLength": 100,
              "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]*$",
              "description": "`utm_source`: where visitors come from, such as instagram."
            },
            "medium": {
              "type": "string",
              "maxLength": 100,
              "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]*$",
              "description": "`utm_medium`: the kind of traffic, such as social."
            },
            "campaign": {
              "type": "string",
              "maxLength": 100,
              "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]*$",
              "description": "`utm_campaign`: the campaign, such as autumn-menu."
            },
            "term": {
              "type": "string",
              "maxLength": 100,
              "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]*$",
              "description": "`utm_term`: a keyword, mostly for paid search."
            },
            "content": {
              "type": "string",
              "maxLength": 100,
              "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]*$",
              "description": "`utm_content`: tells apart links of one campaign."
            }
          },
          "description": "UTM tags, each up to 100 characters, trimmed and URL-encoded. An empty one adds nothing."
        },
        {
          "type": "null"
        }
      ],
      "description": "The UTM tags on every address in the message, which its Rizamo links send people to (`Get a short link` shows each address), so your analytics see the network and the automation. Null: none."
    },
    "publicReplies": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "After the private reply goes out, one of these is posted under the comment, picked at random. Empty: none."
    },
    "markDone": {
      "type": "boolean",
      "description": "Marks the comment's thread done in the inbox once the private reply went out."
    },
    "followGate": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "ask": {
              "type": "string",
              "minLength": 1,
              "maxLength": 5000,
              "description": "The first private reply, sent instead of the message, above the button: ask them to follow and reply, such as \"Follow us, then tap below or reply LINK to get it\". Up to 640 characters, sent as written."
            },
            "reminder": {
              "type": "string",
              "minLength": 1,
              "maxLength": 5000,
              "description": "Sent once, above the button, when they reply without following. The next reply is checked again. Up to 640 characters, sent as written."
            },
            "button": {
              "type": "string",
              "minLength": 1,
              "maxLength": 20,
              "description": "The button under the ask and the reminder, up to 20 characters: tapping it sends its title as their reply, and any reply opens the gate. Left out: I'm following on a new automation, the title it had on an update."
            }
          },
          "required": [
            "ask",
            "reminder"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "oncePerPerson": {
      "type": "boolean",
      "description": "One message per person for this automation, however many times they comment. On by default."
    },
    "stats": {
      "type": "object",
      "properties": {
        "triggered": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Comments that matched."
        },
        "sent": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "People who got the message with the link."
        },
        "waiting": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Matched comments still on their way, and people the follow gate is waiting on."
        },
        "skipped": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Matched comments not answered: the person already got it, or the comment was too old."
        },
        "failed": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "expired": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "People the follow gate waited on in vain: no reply within 7 days. triggered is sent, waiting, skipped, failed and expired added up."
        },
        "failures": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "reason": {
                "enum": [
                  "already_sent",
                  "too_old",
                  "refused",
                  "unclear",
                  "expired"
                ],
                "type": "string",
                "description": "already_sent: this person already got this automation's message, or may have (an unclear one). too_old: the comment was more than 7 days old when Rizamo got to it, past Meta's window. refused: Meta refused this message, such as a person who does not take messages, or a comment that already got its one private reply (another app or team with the account sent first), or would have: the comment was deleted before the message went out (skipped); the run's `error` says which. unclear: Rizamo could not tell whether it went out, so it never sends it again. expired: the follow gate got no reply within 7 days of its last message. A refused login or permission is no reason here: the automation is paused with it, and its runs wait as they were, to go out once it is resumed within the 7 days."
              },
              "count": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "reason",
              "count"
            ]
          },
          "description": "Skipped, failed and expired runs by reason, most first."
        },
        "linkClicks": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ],
          "description": "Clicks on the message's Rizamo links. Null while clicks are not counted."
        },
        "followGate": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "asked": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991,
                  "description": "People asked to follow and reply."
                },
                "followed": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991,
                  "description": "People who replied as followers and got the message: the conversions."
                },
                "reminded": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991,
                  "description": "People who replied without following and got the reminder."
                },
                "expired": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                }
              },
              "required": [
                "asked",
                "followed",
                "reminded",
                "expired"
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "Null when the automation has no follow gate and never had runs with one."
        },
        "sentToday": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Messages the account sent through automations in the last 24 hours, against the daily cap."
        },
        "dailyCap": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Messages an account sends through automations in 24 hours at most; more wait for room, within Meta's 7 days."
        }
      },
      "required": [
        "triggered",
        "sent",
        "waiting",
        "skipped",
        "failed",
        "expired",
        "failures",
        "linkClicks",
        "followGate",
        "sentToday",
        "dailyCap"
      ]
    },
    "createdBy": {
      "$ref": "#/$defs/Actor"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "profileId",
    "accountId",
    "network",
    "name",
    "status",
    "pausedReason",
    "networkPostId",
    "postId",
    "armed",
    "keywords",
    "match",
    "exclude",
    "message",
    "links",
    "utm",
    "publicReplies",
    "markDone",
    "followGate",
    "oncePerPerson",
    "stats",
    "createdBy",
    "createdAt",
    "updatedAt"
  ],
  "$defs": {
    "Actor": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "agent"
            },
            "agent": {
              "anyOf": [
                {
                  "enum": [
                    "claude",
                    "chatgpt",
                    "claudecode",
                    "cursor",
                    "codex",
                    "gemini",
                    "perplexity",
                    "openclaw",
                    "n8n",
                    "make",
                    "zapier"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "name": {
              "type": "string"
            },
            "agentId": {
              "type": "string"
            },
            "onBehalfOf": {
              "type": "object",
              "properties": {
                "userId": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "userId",
                "name"
              ],
              "description": "The person whose agent it is, who connected it and whom it acts as, with their role: \"Ana via Claude Code\". Events from before 2026-11-02 have it too, with the person's name now. Left out of an agent with no person, and of other records from before. After the person's erasure, `name` is \"A former member\" and `userId` empty."
            }
          },
          "required": [
            "type",
            "agent",
            "name"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "user"
            },
            "userId": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "initials": {
              "type": "string"
            }
          },
          "required": [
            "type",
            "userId",
            "name",
            "initials"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "api_key"
            },
            "keyId": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "type",
            "keyId",
            "name"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "automation"
            },
            "automationId": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "type",
            "automationId",
            "name"
          ]
        }
      ]
    },
    "Network": {
      "enum": [
        "instagram",
        "facebook",
        "threads",
        "linkedin",
        "tiktok",
        "youtube",
        "x",
        "pinterest",
        "google"
      ],
      "type": "string"
    }
  }
}