Create an Instagram automation
const url = 'https://app.whatsetter.com/api/v1/instagram/automations';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"account_id":"68f1c2d3e4f5a6b7c8d9e0f1","name":"Buyer\'s guide","trigger":{"on":"comment","posts":"next","keywords":["GUIDE"]},"public_replies":["Sent you a DM 👀","Check your messages!"],"dm_message":"Here is the guide 👇","link":{"url":"https://example.com/guide","label":"Get the guide"},"ai_handoff":true,"active":false}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://app.whatsetter.com/api/v1/instagram/automations \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "account_id": "68f1c2d3e4f5a6b7c8d9e0f1", "name": "Buyer'\''s guide", "trigger": { "on": "comment", "posts": "next", "keywords": [ "GUIDE" ] }, "public_replies": [ "Sent you a DM 👀", "Check your messages!" ], "dm_message": "Here is the guide 👇", "link": { "url": "https://example.com/guide", "label": "Get the guide" }, "ai_handoff": true, "active": false }'Creates an automation on an account: when someone comments one of its
words (on every post, on the posts published from now on, or on some
posts), replies to a story, mentions the account in a story, or sends
a private message with one of its words, it may answer in public
under the comment (public_replies, one picked each time), then sends
one private message (dm_message; with link, a card whose button
opens it after the person taps; with follow_gate, after asking them
to follow the account), and the agent continues the conversation
(ai_handoff, the account’s own agent unless campaign_id names
another).
It is created off (active: false) unless you send active: true: an active automation writes to real people. Going live is
refused with 409 automation_conflict (and the automation in the way,
in conflict) when a live automation of the account already watches
the same posts for the same words: one comment fires one automation
only. Requires scope instagram:write.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”On create, name, trigger (on, and keywords or any_word: true) and dm_message are required. On change, only the fields sent change.
object
Create only: required when the workspace has several Instagram accounts.
True: it writes to real people from now on.
object
What fires it. Read back, ref_link is an automation made in the dashboard on an ig.me link.
One of these words fires it (accents and case ignored).
Every comment or message fires it
Comments only: public replies under the comment, one picked each time. Empty = none.
The private message people receive (one per comment
A link delivered as a card with a button once the person taps the button under the private message. null removes it.
object
A public https URL.
The button that opens the link.
The button under the private message that asks for the link.
The card’s title.
Ask the person to follow the account before the link. null removes it.
object
The agent that continues (GET /campaigns, its id or campaign_id). Default: the account’s own.
The agent takes the conversation over after the automation.
Example
{ "account_id": "68f1c2d3e4f5a6b7c8d9e0f1", "name": "Buyer's guide", "trigger": { "on": "comment", "posts": "next", "keywords": [ "GUIDE" ] }, "public_replies": [ "Sent you a DM 👀", "Check your messages!" ], "dm_message": "Here is the guide 👇", "link": { "url": "https://example.com/guide", "label": "Get the guide" }, "ai_handoff": true, "active": false}Responses
Section titled “Responses”Created (off unless active was true)
object
object
object
What fires it. Read back, ref_link is an automation made in the dashboard on an ig.me link.
One of these words fires it (accents and case ignored).
Every comment or message fires it
object
object
The agent that continues (its campaign_id).
object
Times it fired
Private messages it sent.
People who opened its link (once per person).
Example
{ "data": { "trigger": { "on": "comment", "posts": "all" } }}Missing, unknown or revoked API key
object
object
Examplegenerated
{ "error": { "code": "example", "message": "example" }}The key lacks the required scope (insufficient_scope), the plan does not have this part of the API (not_in_plan), or Instagram is not enabled on the workspace (instagram_not_enabled, Instagram routes)
object
object
Examplegenerated
{ "error": { "code": "example", "message": "example" }}Resource not found in this workspace
object
object
Examplegenerated
{ "error": { "code": "example", "message": "example" }}automation_conflict: a live automation of the account already watches the same posts for the same words. conflict names it.
object
object
Example
{ "error": { "code": "automation_conflict", "message": "\"Buyer's guide\" is already live on the same post with the keyword \"guide\". Only one can be active, otherwise people would receive the same thing twice.", "conflict": { "id": "6900a1b2c3d4e5f6a7b8c9d0", "name": "Buyer's guide", "reason": "all_posts", "keyword": "guide" } }}Invalid parameter or body (also an invalid or expired cursor)
object
object
Examplegenerated
{ "error": { "code": "example", "message": "example" }}