Instagram Messaging SDK

Sociova β€” Automate Instagram with clean Node.js code

Stop writing repetitive fetch calls and JSON payloads. Sociova wraps the Instagram Messaging endpoints into simple functions so you can ship faster. Works great for bots, CRMs, automations, and internal tools.

Minimal setup (just token + recipient id)
Built-in helpers for messages, attachments, reactions
Copy-paste friendly examples
Why developers use Sociova

SDK-focused DX: clean methods, consistent payload shapes.

Manual API handling
None
Setup time
1 min
Designed for Node.js runtimes and Next.js API routes.
Clean Instagram messaging API wrapper

No more manual URL building, headers, and complex JSON bodies. Use straightforward methods like sendMessage(), sendAttachment(), and sendReaction().

Built for automations + bots

Perfect for quick replies, support bots, lead capture flows, and CRM integrations β€” without rewriting request logic across projects.

Attachment support (images + more)

Send multiple images via attachments array. Keep your message payloads consistent and predictable.

Reactions + interactive actions

React/unreact on messages with a single call. Great for quick UX signals, confirmations, and lightweight automation feedback.

Next.js friendly

Works smoothly inside Next.js Route Handlers (app/api/*) and Node scripts β€” ideal for building dashboards and backend workflows.

Developer-first documentation

Quickstart examples you can paste into your project. Less reading, more shipping.

Documentation

Quickstart

Install Sociova, add your access token to environment variables, and send your first Instagram message.

Run in terminal:

npm i sociova
1) Environment variables

Add these variables to your environment (local or deployment).

INSTAGRAM_USER_ACCESS_TOKEN="your-access-token"
RECIPIENT_ID="the-igsid-you-want-to-message"
MESSAGE_ID="for reactions (optional)"
Tip: keep tokens in environment variables. Don’t commit them to git.
What Sociova abstracts for you
  • Builds the correct request body for messages, attachments, stickers, and reactions.
  • Adds headers (Authorization + JSON content type) automatically.
  • Keeps your code readable and consistent across projects.
2) Use the SDK

Example usage (copy-paste ready):

import { InstaClient } from "sociova";

const client = new InstaClient({
  auth: process.env.INSTAGRAM_USER_ACCESS_TOKEN!,
});

// 1) Send a text message
await client.sendMessage({
  recepientId: process.env.RECIPIENT_ID!,
  message: "Hey! This was sent via Sociova SDK πŸš€",
});

// 2) Send multiple images
await client.sendAttachment({
  recepientId: process.env.RECIPIENT_ID!,
  attachments: [
    { type: "image", payload: { url: "https://humkind.in/logo.png" } },
    { type: "image", payload: { url: "https://humkind.in/favicon.ico" } },
  ],
});

// 3) React to a specific message
await client.sendReaction({
  recepientId: process.env.RECIPIENT_ID!,
  messageId: process.env.MESSAGE_ID!,
  reaction: "love", // or "😊" or "πŸŽ‰" or "πŸ‘‹"
  action: "react",  // "unreact" to remove
});
Use inside Node scripts or server routes (Next.js API routes recommended).
Advanced Messaging

Interactive Button Templates

Send interactive button templates in Instagram DMs. Perfect for lead capture, onboarding flows, support menus, and call-to-action prompts.

A button template message allows you to send a message that contains text and up to three attached buttons that allow the message recipient to choose from different options. The buttons can open web pages in the in-app browser or send the recipient's selection to you via the messaging_postback webhook notification. You can then send information about the selection back to the recipient.

What this enables
  • Website redirect buttons
  • Postback buttons for automation logic
  • Multi-option user flows inside DMs
  • Structured CTA messaging
  • Best CRM Architecture
Example: Send a Button Template
await client.sendButtonTemplate({
  recipientId: process.env.RECIPIENT_ID!,
  text: "What would you like to do?",
  buttons: [
    {
      type: "web_url",
      title: "Visit Website",
      url: "https://yourwebsite.com"
    },
    {
      type: "postback",
      title: "Start Now",
      payload: "START_FLOW"
    }
  ]
});
When a user clicks a postback button, the payload string will be received in your webhook event β€” enabling automation workflows.
Sociova is client-side friendly in Node environments β€” keep tokens server-side for safety.