Large Language ModelsGenerate imagesGenerate videos

AI Agent for Instagram Marketing: DMs, Posts and n8n

Build an AI agent that replies to Instagram DMs, drafts captions, generates images and publishes posts on a schedule. See the n8n workflow node by node, the Instagram API limits to respect, which language models fit each task, and what the setup costs to run.

AI Agent for Instagram Marketing: DMs, Posts and n8n
Cristian Da Conceicao
Founder of Picasso IA

Most Instagram accounts hit the same wall once they pass a few thousand followers. Messages pile up overnight, comments wait for an answer, and the next post still needs a caption, a picture and a time slot. An AI agent for Instagram marketing takes that routine off your plate. It reads each incoming DM, decides what to do, writes the reply, and can even produce and publish tomorrow's post while you stay in charge of tone and limits.

This article lays out a setup that works with today's tools. n8n runs the workflow, a large language model acts as the brain, the official Instagram API is the channel, and the Picasso IA Image model supplies the pictures that fill your feed. You get the architecture, the node-by-node build for DMs and posts, the safety rules, and a realistic cost picture.

What an Instagram AI Agent Really Does

An agent is not a fancy auto-responder. It is a language model wrapped in a loop: it receives an event such as a DM, a comment or a scheduled trigger, reads the context, calls a tool when it needs data, and produces an action. In n8n that loop lives inside the AI Agent node, which connects a chat model, a memory store and a set of tools.

Overhead view of a wooden desk with a laptop showing a workflow diagram, a phone with a grid of product photos and a notebook with flowchart sketches

Agent vs Chatbot

Older Instagram automation tools match trigger phrases and fire canned replies. An agent behaves differently, and the gap shows up fast in real conversations.

FeatureRule-based chatbotAI agent
RepliesFixed answer per trigger phraseWritten fresh for each message
ContextForgets the previous messageRemembers the whole thread
ActionsSends one canned textLooks up stock, orders and calendars through tools
SurprisesFalls back to "I did not get that"Reasons about the request or hands off
Setup effortQuick but brittleMore setup, far more flexible

The Three Jobs It Handles

  1. Direct messages. Answers product questions, shipping times and opening hours, qualifies leads and books calls.
  2. Comments. Replies in public, and when someone asks about price or availability, moves the conversation into a private DM.
  3. Posts. Drafts the caption, generates the image or clip, picks the slot and publishes.

💡 Pick one job first. DMs pay off fastest because every answered message is a visible win. Add the post pipeline once the replies feel solid.

A ceramic studio owner smiling as she reads a customer message on her phone behind a rustic counter

The Stack You Need

Four pieces make the system: an Instagram professional account with a Meta app, n8n as the engine, a language model for decisions and writing, and an image and video generator for the feed. Each piece is replaceable, but this combination is the one with the least friction for a small team.

Instagram Account Requirements

You need a professional account (Business or Creator) and a Meta developer app. Request only the permissions you use: instagram_business_manage_messages for DMs, instagram_business_manage_comments for comment replies and instagram_business_content_publish for posting. While the app sits in development mode, only accounts with a role on the app can message it, which is ideal for testing. Going live for the public requires Meta's app review, so record a short screencast of each permission in use before you submit.

n8n as the Orchestrator

n8n is a workflow tool where each step is a node. This build needs five node types:

  • Webhook receives DM and comment events from Instagram.
  • Schedule Trigger starts the post pipeline on posting days.
  • AI Agent holds the model, memory and tools.
  • HTTP Request calls the Instagram API and the Picasso IA API.
  • IF and Switch route messages and run safety checks.

You can self-host n8n for free or use its paid cloud plan. The workflow is identical in both.

Close-up of a developer's hands typing on a laptop with a blurred workflow of connected boxes on the screen behind

Picking the Language Model

The AI Agent node accepts several providers. Test your system prompt on a few models in the Picasso IA catalogue before you wire one into n8n, and compare the tone side by side.

ModelBest use in this build
Claude Sonnet 5Natural-sounding DM replies and long conversation threads
GPT 5.6 LunaFast replies when message volume is high
Gemini 3.5 FlashCheap routing and classification, plus reading photos customers send
Kimi K2.6Tool-calling loops where the agent chooses between several actions
GPT 5 StructuredClean JSON output for the caption and image prompt pipeline

💡 Use two models. A small, fast one for routing and classification, and a stronger one for the replies customers actually read. It keeps token costs low without hurting quality.

Two marketers comparing printed caption drafts between two open laptops in a bright agency room

Build the DM Agent in n8n

The DM workflow is the heart of the system. It has four moving parts, and each one maps to a handful of nodes.

Webhook Trigger and Verification

Meta verifies your endpoint once. It sends a GET request with hub.mode, hub.verify_token and hub.challenge, and your workflow must return the challenge value when the token matches. In n8n, create a Webhook node that accepts GET and POST on the same path. Send GET requests to an IF node that compares the token, then answer with a Respond to Webhook node. Subscribe to the messages field, and add comments if you handle those too.

POST requests carry the real events. Extract the sender ID and the message text, and drop any event flagged is_echo. Without that filter the agent answers its own messages in an endless loop.

Memory, Prompt and Tools

Attach three things to the AI Agent node:

  • Memory. A Simple Memory node that uses the sender ID as the session ID, so every customer gets a separate thread.
  • System prompt. Your brand voice, the facts the agent may state, and the boundaries it must respect.
  • Tools. A sheet lookup for your catalog, an HTTP Request tool for order status, a calendar for bookings and a handoff tool.

Here is a starting system prompt you can adapt:

You are the Instagram assistant for Clay & Wick, a small candle and ceramics shop.
Reply in one to three short sentences. Be friendly and plain.
Use only the product sheet and policies returned by your tools.
Never invent prices, stock levels or delivery dates.
If you cannot answer, or the customer sounds upset, call the handoff tool
and say a teammate will reply today.
In your first reply, mention that you are an automated assistant.

The rule about never inventing facts matters more than any other line. Models fill gaps with confident guesses, so give the agent a product sheet to read and forbid everything outside it.

Sending the Reply

Add an HTTP Request node that sends a POST request to https://graph.instagram.com/<VERSION>/me/messages with your access token in the Authorization header and this JSON body:

{
  "recipient": { "id": "<SENDER_ID>" },
  "message": { "text": "<AGENT_REPLY>" }
}

A Wait node of a few seconds before the send makes the exchange feel natural instead of robotic.

A hand reaching for a phone beside a flat white with latte art on a wooden cafe counter

When to Hand Off to a Human

Some conversations should never stay with the model. Route these to a person:

  • Refund requests and complaints
  • Legal, medical or safety questions
  • Custom quotes and bulk orders
  • Anything the model flags as low confidence

The handoff tool should tag the thread in your sheet, ping your team in chat, and set a paused flag so the agent stays silent on that thread for 24 hours.

Automate Posts From Idea to Publish

The Scheduled Content Pipeline

The post pipeline is a second workflow with a different trigger:

  1. A Schedule Trigger fires at 8:00 on posting days.
  2. A Google Sheets node pulls the next row marked ready, with topic, product and offer.
  3. The AI Agent drafts a caption and an image prompt and returns them as JSON.
  4. The image step generates the picture (the next two sections).
  5. Two HTTP Request nodes create the media container and publish it.
  6. The sheet row flips to posted and stores the permalink.

For the first two weeks, add an approval step. Send the draft to your inbox and pause the workflow with a Wait node until you approve it. Once the drafts match your voice, remove the pause.

A woman arranging a hand-poured candle on a linen cloth beside a softbox in a small home studio

Generating Images for Posts

The Instagram grid rewards a consistent look, so pick one model per content type and reuse the same style sentence in every prompt.

A prompt template that works has four parts: subject, setting, light direction, lens. For example: "hand-poured soy candle on a linen cloth, morning window light from the left, 50mm lens, shallow depth of field". Keep the style sentence fixed and let the language model change only the subject.

Reels With AI Video

Reels get reach, and a still product photo becomes a short clip in one step. Picasso IA Video generates video from text or an image, Seedance 2.5 Lite produces clips up to 10 seconds, and Veo 3.1 Lite adds native audio. For Reels through the API, set media_type to REELS and pass a public video_url. Then poll the container's status_code until it reads FINISHED before you publish.

A young creator filming a vertical video with a phone on a tripod in a sunlit kitchen while pouring coffee

Publishing via the Graph API

Publishing takes two calls:

  1. POST https://graph.instagram.com/<VERSION>/<IG_ID>/media with image_url and caption returns a container ID.
  2. POST https://graph.instagram.com/<VERSION>/<IG_ID>/media_publish with creation_id set to that ID publishes the post.

The image URL must be public, and Instagram accepts JPEG for image posts. If your generator returns PNG or WebP, add a conversion step before the first call.

How to Use Picasso IA in n8n

The Picasso IA Image model is available through the Picasso IA API, so n8n can generate every post image on its own. The API follows a create, poll, fetch pattern, the same way most prediction APIs work.

Stepn8n nodeSetting
1. Get a tokenNoneCreate an API token on the Picasso IA API page
2. Store itCredentialsHeader Auth, name Authorization, value Bearer <TOKEN>
3. Start the jobHTTP RequestPOST to https://api.picassoia.com/v1/models/picassoia/picassoia-image/predictions with body {"input": {"prompt": "<IMAGE_PROMPT>"}}
4. PauseWait10 to 20 seconds
5. Check statusHTTP RequestGET https://api.picassoia.com/v1/predictions/<ID>
6. BranchIFsucceeded continues, failed alerts you, anything else loops back to Wait
7. Use the fileSetMap the output URL into image_url for the publish call

A few details save debugging time:

  • Prompts can run up to 4,000 characters, so keep the style sentence and the subject together in one string.
  • An account runs 5 predictions at once, shared across tokens. For a weekly batch, use Loop Over Items with a small batch size.
  • Run one test prediction and read the JSON before you map fields, because output field names depend on the model.
  • The same pattern works for Picasso IA Video at picassoia/picassoia-video and Seedance 2.5 Lite at picassoia/seedance-2.5-lite.
  • API access depends on your plan, so check the Picasso IA API page before you build around it.

💡 Ask the language model for a field called image_prompt, then append your fixed style sentence in a Set node. The brand look stays identical across every post, whatever the model writes.

Guardrails That Protect Your Account

Messaging Windows and Limits

Instagram sets firm rules on who can message whom and when. Build them into the workflow instead of hoping the agent behaves.

SituationRule
Reply to a DMAllowed within 24 hours of the customer's last message
Reply after 24 hoursOnly a human agent can answer, up to 7 days, with the human agent tag
Private reply to a commentOne per comment, within 7 days of the comment
First contactThe customer starts the thread, unsolicited DMs are not allowed
PublishingA daily cap applies to API posts, so check the current number before launch

Meta updates these limits from time to time, so read the current rules before you go live and store the values in one n8n variable you can change quickly.

Say it is automated. Tell people in the first reply that they are talking to an assistant, and offer a way to reach a person, such as typing "human". It builds trust, it keeps you on the safe side of platform and local rules, and it lowers frustration when the agent reaches its limits. Keep the voice consistent with your captions so the account sounds like one brand, not two.

Logs and a Review Queue

Log every incoming and outgoing message with a timestamp, the sender ID, the tools the agent called and the final reply. A simple sheet or database table is enough. Each week, read 20 random threads and fix the system prompt or the product sheet wherever the agent stumbled.

Add a kill switch too: a variable or a sheet cell that the first IF node checks. When it reads paused, the agent stays silent. Pair it with an n8n error workflow that alerts you whenever a node fails, so a broken token never goes unnoticed for days.

A community manager with round glasses highlighting lines on printed conversation logs at a quiet desk

The Real Cost of Running It

The Instagram API itself carries no usage fee, so the bill comes from four places.

ItemHow it is billed
n8nFree when self-hosted, a monthly plan on the cloud version
Language modelPer token, and DM replies are short, so usage stays low
Images and clipsPer generation, or drawn from your Picasso IA plan
Your timeA day or two for setup, then a weekly review

Measure three numbers from week one: first reply time, the share of threads resolved without a human, and the number of DMs that end in a sale or booking. If most threads still end in a handoff after a month, the cause is usually missing facts in the product sheet, not the model. Fill the gaps, replay the same conversations, and the handoff rate drops.

Start small: one account, one language and five common questions. Once those run cleanly, add comments, then the post pipeline, then Reels.

A small shop owner in a denim shirt reading a tablet at a sunny cafe table with a notebook and iced coffee

Try It on Picasso IA

Plan a first weekend:

  • Saturday morning: create the Meta app, connect your professional account and get the echo test working in n8n.
  • Saturday afternoon: write the system prompt and the product sheet, then test 20 real questions from your inbox.
  • Sunday: build the post pipeline with one image and one approval step.

Your feed needs pictures before the automation matters, so start there. Open Picasso IA Image, paste the prompt template from this article with your own product, and generate your first post image. Then animate it with Picasso IA Video or Seedance 2.5 Lite and send it through the Reel pipeline above. Experiment with a few models from the catalogue, keep the look that fits your brand, and let the agent handle the repetition while you focus on your customers.

Share this article