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.

Docs Summary

Instagram API with Instagram Login

This API allows Instagram professionals (businesses & creators) to use your app to manage their Instagram presence.

What the API can be used for
  • Comment moderation — Manage and reply to comments on their media
  • Content publishing — Get and publish their media
  • Media Insights — Get insights on their media
  • Mentions — Identify media where they’ve been @mentioned by other Instagram users
  • Messaging — Send and receive messages with customers or people interested in their Instagram account
Note

This API setup does not require a Facebook Page to be linked to the Instagram professional account.

Scope update (important)

To ensure consistency between scope values and permission names, new scope values are being introduced for the Instagram API with Instagram Login.

instagram_business_basicinstagram_business_content_publishinstagram_business_manage_messagesinstagram_business_manage_comments

These will replace the existing scope values business_basic, business_content_publish, business_manage_comments, business_manage_messages respectively.

The old scope values will be deprecated on January 27, 2025. Update your code before this date to avoid disruptions.

Message ID (important for reactions)

A message_id is not something you can “generate” on your own. You can only get it when your app receives an incoming event, like a comment, DM, or mention, through an established webhook connection. That incoming webhook payload includes the message_id you use for actions like react/unreact.

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!,
});
const getUser = await client.getUser({

    fields:"username, user_id"
})
    
console.log(getUser)

Use inside Node scripts or server routes (Next.js API routes recommended).

Send Automated Messages


// 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
});
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.

Generic Template

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

The generic template allows you to send a structured message that includes an image, text and buttons. A generic template with multiple options described in the elements array will send a horizontally scrollable carousel of items, each composed of an image, text and buttons.

What this enables
  • Website redirect buttons
  • Postback buttons for automation logic
  • Multi-option user flows inside DMs
  • Structured CTA messaging
  • Best CRM Architecture
  • Easy Integration
Example: Send a Button Template
const sendGenericTemplate = await client.sendGenericTemplate({
  recipientId: process.env.RECIPIENT_ID,
  elements: [
    {
      title: "Sociova — Quick Demo",
      image_url: "https://humkind.in/favicon.ico",
      subtitle: "Send messages, buttons & templates easily",
      default_action: {
        type: "web_url",
        url: "https://humkind.in",
      },
      buttons: [
        {
          type: "web_url",
          url: "https://humkind.in",
          title: "Visit Us",
        },
        {
          type: "postback",
          title: "Start Flow",
          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.