Social Inbox Agentのロゴ

Social Inbox Agent

コミュニティ
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

概要

公開者kevinbadi
リポジトリai-os-skills
スキル名social-inbox-agent
スター
73
フォーク
29
同梱ファイル
2
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 2個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    kevinbadiがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Social Inbox Agent」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/kevinbadi/ai-os-skills/tree/main/social-inbox-agent
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

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
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでSocial Inbox Agentを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にSocial Inbox Agentを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Social Inbox Agentは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

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

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「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

TypingMindでSocial Inbox Agentを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Social Inbox Agentはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにSocial Inbox Agentをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/kevinbadi/ai-os-skills/tree/main/social-inbox-agentを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Social Inbox Agentを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Social Inbox Agentで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもSocial Inbox Agentを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Social Inbox Agent」は無料ですか?

kevinbadiがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇