Skip to content

Button templates in DMs, instead of a bare URL #24

Description

@CharanMN7

The problem

DMs are plain text. A bare URL in an Instagram DM is unappealing and converts worse than a tappable button.

What to build

Support Meta's button template on the private-reply send in src/meta.ts, so a rule can define up to three web_url buttons.

{
  "recipient": { "comment_id": "..." },
  "message": {
    "attachment": {
      "type": "template",
      "payload": {
        "template_type": "button",
        "text": "Here's the guide!",
        "buttons": [
          { "type": "web_url", "url": "https://…", "title": "Get the guide" }
        ]
      }
    }
  }
}

Meta's limits, which are not negotiable

Limit Value
Buttons per message 3
Button title 20 characters
Template body text 640 characters (not the 1,000 plain text allows)

Truncate rather than error, and warn in the rule form when the DM text exceeds 640 characters with buttons enabled.

The part that needs care

Fall back to plain text when Meta rejects the template — but only then.

Meta returns errors for template rejection and for a closed messaging window and for an already-consumed private reply. Retrying the latter two as plain text will fail again and overwrite the true error with a misleading one, which makes the Sends log actively harmful for debugging.

Match the rejection reason and fall back only for genuine template rejections. Record which path was taken.

Acceptance criteria

  • Rule form accepts up to 3 buttons (label + URL), validated
  • Titles truncated to 20 chars, body to 640, with a warning shown before saving
  • Plain-text fallback fires only for template rejection, never for window-closed or reply-consumed
  • The Sends log distinguishes a template send from a fallback send
  • Tests for the limits and for the error discrimination

Where to look

  • src/meta.tssendPrivateReply
  • src/process.ts, src/routes/admin.ts, migrations/

Pairs well with tracked links.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: automationTriggers, keywords, DM content, delivery behavioureffort: mediumA few sessions. Touches several files.enhancementNew feature or requestroadmapA planned feature from the README roadmap

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions