MyComm docs
Menu

Data

Automation

Answer inbound messages automatically with keyword rules and an away message, and test a rule before it goes live.

Automation rules belong to a line and run when a message arrives in it. There are two kinds:

Type When it runs
keyword The inbound text matches one of the rule's keywords. Rules are checked in order (position); the first match runs. A line holds up to 200.
away The message arrives outside the line's business hours. A line has at most one, with no match.

A keyword rule#

curl -sS -X POST "$MYCOMM_URL/v1/lines/$LINE_ID/automation-rules" \
  -H "Authorization: Bearer $MYCOMM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "keyword",
    "name": "Opening hours",
    "match": {"mode": "contains", "keywords": ["hours", "open"]},
    "actions": [
      {"type": "reply", "body": "We are open 9 to 5, Monday to Saturday."},
      {"type": "tag", "tag": "hours-question"}
    ]
  }'
  • match.mode is exact, starts_with or contains; up to 20 keywords of up to 30 characters; matching ignores case unless case_sensitive is true. The opt-out and opt-in words (STOP and the like) are reserved: they are handled before any rule.
  • A rule has 1 to 5 actions: reply (a literal body or a template_id, not both), add_to_group, remove_from_group, tag (a slug), mark_read and archive.
  • cooldown_minutes (default 720, up to 10,080) stops the same rule answering the same conversation again too soon.

Creating and changing rules needs automation:write, which a key limited to lines never has; reading and testing needs automation:read.

Test before you enable#

POST /v1/lines/{id}/automation-rules/test takes the text of an inbound message (and optionally a contact_id and the time at) and answers what would happen, without sending or writing anything: the rule that would run, its actions, the reply rendered for that contact with its segments, and an outcome:

outcome Meaning
applied The actions would run.
skipped:cooldown The rule ran for this conversation recently.
skipped:channel_cap The channel already sent its limit of automatic replies this hour.
skipped:loop_guard Two automatic senders are answering each other, or the conversation is paused for that reason.
no_match No rule fits, or the message runs no automation (an opt-out word, for example).

What happened in production#

GET /v1/automation-runs lists the evaluations, newest first, with the rule, the conversation, the triggering message, the outcome and what each action did (queued with the message id, applied, failed with a code, or skipped). Filter by line_id, rule_id, conversation_id or outcome.

Automatic replies go through the same checks as any message: opt-outs, consent, quiet hours and the SIM's limits still apply.