Social Inbox Agent logo

Social Inbox Agent

Community
kevinbadi
social-inbox-agent

AI-powered social inbox agent — responds to inbound DMs on Instagram, Twitter, LinkedIn, and YouTube as {{PERSONA_NAME}} via Late API + Gemini, with PostgreSQL message tracking

Overview

Publisherkevinbadi
Repositoryai-os-skills
Skill namesocial-inbox-agent
Stars
73
Forks
29
Bundled files
2
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by kevinbadi on GitHub. Read the source before you install it.

Installation

Install the Social Inbox Agent AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/kevinbadi/ai-os-skills/tree/main/social-inbox-agent
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/kevinbadi/ai-os-skills.git /tmp/ai-os-skills
mkdir -p .claude/skills
cp -r /tmp/ai-os-skills/social-inbox-agent .claude/skills/social-inbox-agent
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Social Inbox Agent in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Social Inbox Agent on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Social Inbox Agent is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

What It Does

Automatically responds to inbound DMs across all connected social platforms. Uses PostgreSQL as the single source of truth for all message tracking — no file-based state, no race conditions, no self-reply loops.

How to Run

bash
# Process all unreplied messages
node skills/social-inbox-agent/scripts/dm-response-agent.js

# Dry run — see what would be sent without sending
node skills/social-inbox-agent/scripts/dm-response-agent.js --dry-run

# Limit to N conversations
node skills/social-inbox-agent/scripts/dm-response-agent.js --limit 5

# Filter to specific platform
node skills/social-inbox-agent/scripts/dm-response-agent.js --platform instagram

Requires env vars: LATE_API_KEY, GEMINI_API_KEY, DATABASE_URL

Message Workflow

1. FETCH — Get all conversations from Late API (GET /v1/inbox/conversations)
2. For each conversation:
   a. FETCH messages (GET /v1/inbox/conversations/{id}/messages)
   b. SYNC — Store all incoming messages in PostgreSQL (social_inbox table)
   c. SAFETY CHECKS — Run all anti-spam guards (see below)
   d. FIND — Identify the latest unreplied incoming message
   e. GENERATE — Create reply via Gemini with conversation context
   f. SEND — Post reply via Late API
   g. TRACK — Atomically store outgoing reply + mark incoming as replied in DB

Database Tracking (social_inbox table)

ColumnPurpose
late_message_idUnique Late API message ID (unique constraint)
late_conversation_idGroups messages by conversation
directionincoming or outgoing
repliedBoolean — has this incoming message been replied to?
replied_atTimestamp of when we replied
reply_textThe reply we sent (or [SKIPPED])
message_textThe original message content
sender_nameWho sent it
platforminstagram, twitter, linkedin, youtube

Key DB queries the agent uses:

  • Is this message already replied? → SELECT replied FROM social_inbox WHERE late_message_id = $1
  • Is this text our own reply? → SELECT id FROM social_inbox WHERE direction = 'outgoing' AND message_text = $1
  • Spam ratio? → SELECT direction, COUNT(*) FROM social_inbox WHERE late_conversation_id = $1 GROUP BY direction

Safety Rules (Anti-Spam)

These were added after a 200-message spam incident on 2026-03-14:

  1. ONE reply per conversation per run — even if 50 unreplied messages exist, sends exactly ONE reply to the latest
  2. Never double-message — if the last message in the conversation is ours (outgoing), skip entirely
  3. Never reply to self — outgoing messages tracked in DB; if conversation's lastMessage matches our DB outgoing text, skip
  4. Spam ratio guard — if outgoing > 2× incoming (and > 3 total), skip the conversation
  5. Pagination-aware — Late API caps at 100 messages; agent cross-references conversation.lastMessage with DB to detect messages beyond the pagination window
  6. Atomic tracking — reply send + DB update in a single transaction; no partial states

Beyond-Pagination Logic

When a conversation has 100+ messages (e.g., after a spam incident), the messages endpoint won't return the newest ones. The agent handles this:

  1. Compares conversation.updatedTime vs last visible message timestamp
  2. If conversation was updated >30s after last visible message → newer message exists
  3. Checks DB: is conversation.lastMessage text one of our outgoing replies? → skip
  4. If not our reply → creates a synthetic incoming record with a text-based ID (base64 of message content), generates reply, tracks in DB
  5. Text-based synthetic IDs ensure the same incoming message always deduplicates, even when updatedTime changes from our own replies

Response Strategy

Loads persona from onboarding-config.json (phase1.*):

  • Persona name, backstory, voice, brand info, target audience, primary CTA

Response Rules

  • Keep replies short (1-3 sentences for simple, up to 5 for detailed questions)
  • No markdown formatting — this is a DM, not a document
  • Max 1-2 emojis per message, only if natural
  • Answer questions first, then guide toward offer if relevant
  • Don't be salesy or pushy — be genuinely helpful
  • Never break character or mention being AI
  • Skip low-effort messages (just emojis, etc.) with [SKIP]

Setup Requirements

  • PostgreSQL with social_inbox table (unique constraint on late_message_id)
  • Late API account with connected social platforms
  • Gemini API key for reply generation
  • Platform account IDs in onboarding-config.json → phase2.platforms.*.late_id

Cron Configuration

Designed to run every 1 minute via cron. Safe for concurrent/isolated runs because all state is in PostgreSQL, not local files.

Schedule: * * * * *
Target: isolated
Command: node skills/social-inbox-agent/scripts/dm-response-agent.js --limit 10

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Social Inbox Agent AI skill do?

AI-powered social inbox agent — responds to inbound DMs on Instagram, Twitter, LinkedIn, and YouTube as {{PERSONA_NAME}} via Late API + Gemini, with PostgreSQL message tracking

Why use Social Inbox Agent on TypingMind?

Because you install it once and use it with any model. Social Inbox Agent is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Social Inbox Agent in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/kevinbadi/ai-os-skills/tree/main/social-inbox-agent. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Social Inbox Agent?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Social Inbox Agent?

As many as you like. As long as a model supports skills, you can use Social Inbox Agent with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Social Inbox Agent AI skill free?

It is published on GitHub by kevinbadi. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇