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.
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.
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.
Feature
Rule-based chatbot
AI agent
Replies
Fixed answer per trigger phrase
Written fresh for each message
Context
Forgets the previous message
Remembers the whole thread
Actions
Sends one canned text
Looks up stock, orders and calendars through tools
Surprises
Falls back to "I did not get that"
Reasons about the request or hands off
Setup effort
Quick but brittle
More setup, far more flexible
The Three Jobs It Handles
Direct messages. Answers product questions, shipping times and opening hours, qualifies leads and books calls.
Comments. Replies in public, and when someone asks about price or availability, moves the conversation into a private DM.
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.
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.
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.
Clean 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.
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:
A Wait node of a few seconds before the send makes the exchange feel natural instead of robotic.
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:
A Schedule Trigger fires at 8:00 on posting days.
A Google Sheets node pulls the next row marked ready, with topic, product and offer.
The AI Agent drafts a caption and an image prompt and returns them as JSON.
The image step generates the picture (the next two sections).
Two HTTP Request nodes create the media container and publish it.
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.
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.
Picasso IA Image Editor Pro edits your real product photos, for example swapping a cluttered background or fixing the light.
GPT Image 2 helps when a post needs legible text on the picture.
Seedream 5 Lite, Nano Banana 2 and Flux 2 Pro are worth testing for lifestyle scenes. Run the same prompt through each and keep the one that fits your brand.
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.
Publishing via the Graph API
Publishing takes two calls:
POST https://graph.instagram.com/<VERSION>/<IG_ID>/media with image_url and caption returns a container ID.
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.
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.
Situation
Rule
Reply to a DM
Allowed within 24 hours of the customer's last message
Reply after 24 hours
Only a human agent can answer, up to 7 days, with the human agent tag
Private reply to a comment
One per comment, within 7 days of the comment
First contact
The customer starts the thread, unsolicited DMs are not allowed
Publishing
A 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.
The Real Cost of Running It
The Instagram API itself carries no usage fee, so the bill comes from four places.
Item
How it is billed
n8n
Free when self-hosted, a monthly plan on the cloud version
Language model
Per token, and DM replies are short, so usage stays low
Images and clips
Per generation, or drawn from your Picasso IA plan
Your time
A 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.
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.