Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

social-media-agent

> 编程语言
Open source

An agent for sourcing, curating, and scheduling social media posts with human-in-the-loop.

2.7K stars0 likes2 views
WebsiteGitHub

About

An agent for sourcing, curating, and scheduling social media posts with human-in-the-loop.

Social Media Agent

This repository contains an 'agent' which can take in a URL, and generate a Twitter & LinkedIn post based on the content of the URL. It uses a human-in-the-loop (HITL) flow to handle authentication with different social media platforms, and to allow the user to make changes, or accept/reject the generated post.

Table of contents

  • Quickstart
    • Environment variables
    • LangGraph Server
  • Full setup
    • Environment variables
    • Authentication
    • Supabase
    • Slack
    • GitHub
  • Usage
    • Generate Post
    • Setup Crons
    • Prebuilt Scripts
  • Setup Agent Inbox
    • Using the deployed inbox
    • Using the local inbox
  • Customization
    • Prompts
    • Post Style

Quickstart

[!TIP] For a visual guide, check out our step-by-step video tutorial that walks you through the account setup process and project configuration.

This quickstart covers how to setup the Social Media Agent in a basic setup mode. This is the quickest way to get up and running, however it will lack some of the features of the full setup mode. See here for the full setup guide.

Running in basic setup mode will lack the following features:
  • Parsing content from GitHub, Twitter or YouTube URLs
  • Ingesting data from Slack, or sending updates to Slack
  • Image selection & uploads

To get started, you'll need the following API keys/software:

  • Anthropic API - General LLM
  • LangSmith - LangSmith API key required to run the LangGraph server locally (free)
  • FireCrawl API - Web scraping. New users get 500 credits for free
  • Arcade - Easy authentication for reading & writing to social media platforms

Setup Instructions

Clone the repository:

bash
git clone https://github.com/langchain-ai/social-media-agent.git
bash
cd social-media-agent

Install dependencies:

bash
yarn install

Set environment variables.

Copy the values of the quickstart .env.quickstart.example to .env, then add the values:

bash
cp .env.quickstart.example .env

Once done, ensure you have the following environment variables set:

bash
# For LangSmith tracing (optional)
LANGSMITH_API_KEY=
LANGSMITH_TRACING_V2=true

# For LLM generations
ANTHROPIC_API_KEY=

# For web scraping
FIRECRAWL_API_KEY=

# Arcade API key - used for fetching Tweets, and scheduling LinkedIn/Twitter posts
ARCADE_API_KEY=

If you plan to post to LinkedIn as an organization (rather than as yourself), you'll also need to set:

bash
# Get the organization ID from the URL of the company page when you're logged in as an admin.
# For example, if the URL is `https://www.linkedin.com/company/12345678/admin/dashboard/`, the organization ID would be `12345678`.
POST_TO_LINKEDIN_ORGANIZATION=true
LINKEDIN_ORGANIZATION_ID=

Install LangGraph CLI

bash
pip install langgraph-cli

Then run the following command to check the CLI is installed:

bash
langgraph --version

Click here to read the full download instructions for the LangGraph CLI.

Start the LangGraph server:

To start the LangGraph server, run this script:

bash
yarn langgraph:in_mem:up

Under the hood, this will execute the following command:

bash
npx @langchain/langgraph-cli dev --port 54367

[!NOTE] The first time running this command (or if a new version of @langchain/langgraph-cli has been released), it will ask you to accept an install for the CLI. Enter y to accept.

Once the server is ready, you can execute the following command to generate a post:

bash
yarn generate_post

You may also modify this script to pass different URLs to generate posts for other content.

This will kick off a new run to generate a post on a LangChain blog post.

To view the output, either inspect it in LangSmith, or use Agent Inbox.

[!TIP] Follow these steps to setup & configure the Agent Inbox: Setup Agent Inbox Guide

Advanced Setup

To use all of the features of the Social Media Agent, you'll need the following:

  • Anthropic API - General LLM
  • Google Vertex AI - For dealing with YouTube video content
  • LangSmith - LangSmith API key required to run the LangGraph server locally (free)
  • FireCrawl API - Web scraping
  • Arcade - Social media authentication and scheduling
  • Twitter Developer Account - For uploading media to Twitter
  • LinkedIn Developer Account - Posting to LinkedIn
  • GitHub API - Reading GitHub content
  • Supabase - Storing images
  • Slack Developer Account (optional) - ingesting data from a Slack channel

Setup Instructions

Clone the repository:

bash
git clone https://github.com/langchain-ai/social-media-agent.git
bash
cd social-media-agent

Install dependencies:

bash
yarn install

Set environment variables.

Copy the values of the full env example file .env.full.example to .env, then update the values as needed.

bash
cp .env.full.example .env

Setup authentication

The agent needs your authorization to read and write to social media platforms. There are two ways to authorize the agent:

  1. Use Arcade (quickest to set up)
  2. Use your own Twitter and LinkedIn developer accounts

You can use either method, but not both.

Arcade setup

Create an Arcade account here. After you register, get an Arcade API key. Set this value as ARCADE_API_KEY in your .env file.

Then, you will need to set these environment variables in your .env file:

  • TWITTER_USER_ID - The ID/email of the Twitter account you want to use to post to Twitter.
  • LINKEDIN_USER_ID - The ID/email of the LinkedIn account you want to use to post to LinkedIn.

Make sure you have the USE_ARCADE_AUTH environment variable set to true to have the graph use Arcade authentication.

If you plan to post to LinkedIn as an organization (rather than as yourself), you'll also need to set:

bash
# Get the organization ID from the URL of the company page when you're logged in as an admin.
# For example, if the URL is `https://www.linkedin.com/company/12345678/admin/dashboard/`, the organization ID would be `12345678`.
LINKEDIN_ORGANIZATION_ID=
POST_TO_LINKEDIN_ORGANIZATION=true

[!NOTE] If you want to upload media to Twitter, you will still need to set up your own Twitter developer account (below) in addition to using Arcade.

If you are only planning to read/write text posts on Twitter, you can use Arcade without any additional setup.

Twitter app setup

You'll need to follow these instructions if you plan on uploading media to Twitter, and/or you are not using Arcade for authorization.

  1. Create a Twitter developer account
  2. Create a new app and give it a name.
  3. Copy the API Key, API Key Secret and Bearer Token and set them as TWITTER_API_KEY, TWITTER_API_KEY_SECRET, and TWITTER_BEARER_TOKEN in your .env file.
  4. After saving, visit the App Dashboard. Find the User authentication settings section, and click the Set up button. This is how you will authorize users to use the Twitter API on their behalf.
  5. Set the following fields:
  • App permissions: Read and write
  • Type of App: Web App, Automated App or Bot
  • App info:
    • Callback URI/Redirect URL: http://localhost:3000/auth/twitter/callback
    • Website URL: Your website URL
  1. Save. You'll then be given a Client ID and Client Secret. Set these as TWITTER_CLIENT_ID and TWITTER_CLIENT_SECRET in your .env file.

Once done, run the yarn start:auth command to run the Twitter OAuth server. Open http://localhost:3000 in your browser, and click Login with Twitter.

After authorizing your account with the app, navigate to your terminal where you'll see a JSON object logged. Copy the token and tokenSecret values and set them as TWITTER_USER_TOKEN and TWITTER_USER_TOKEN_SECRET in your .env file.

LinkedIn app setup

You'll need to follow these instructions if you plan on posting to LinkedIn and are not using Arcade for authorization.

  1. Create a new LinkedIn developer account, and app here
  2. After creating your app, navigate to the Auth tab, and add a new authorized redirect URL for OAuth 2.0. Set it to http://localhost:3000/auth/linkedin/callback
  3. Go to the Products tab and enable the Share on LinkedIn and Sign In with LinkedIn using OpenID Connect products.
If you plan on posting from company pages, you'll need to do the following:
  1. If you plan on posting from company pages, you'll also need to enable the Advertising API product. Furthermore, ensure your personal account has at least one one of the following roles with the company page:
  • ADMINISTRATOR
  • DIRECT_SPONSORED_CONTENT_POSTER
  • RECRUITING_POSTER
  1. Next, ensure your company page has verified the app. You can create a verification link on the Settings tab of your app, then click the Verify button on the company page card.
  2. Once requesting access, you'll need to fill out a form for verification. Once submitted, you should receive an email stating you've been granted developer access which will give you the proper permission to test out the API until it's been approved.
  3. Inside the authorization server file (./src/clients/auth-server.ts), ensure the w_organization_social scope is enabled inside the scopes string in the /auth/linkedin route. Once done, the scopes string should look like this: openid profile email w_member_social w_organization_social
  4. Get the organization ID from the URL of the company page when you're logged in as an admin and set it as the LINKEDIN_ORGANIZATION_ID environment variable. For example, if the URL is https://www.linkedin.com/company/12345678/admin/dashboard/, the organization ID would be 12345678.

[!NOTE] If you plan on only posting from the company account, you can set the POST_TO_LINKEDIN_ORGANIZATION to "true" in your .env file. If you want to choose dynamically, you can set this to true/false in the configurable fields (postToLinkedInOrganization) when invoking the generate_post graph.

This value will take precedence over the POST_TO_LINKEDIN_ORGANIZATION environment variable.

  1. Save the following environment variables in your .env file:
  • LINKEDIN_CLIENT_ID
  • LINKEDIN_CLIENT_SECRET
  1. Run the yarn start:auth command to run the LinkedIn OAuth server. Open http://localhost:3000 in your browser, and click Login with LinkedIn.
  2. After logging in, copy the access_token and sub values from the objects logged to the terminal. Set these values as LINKEDIN_ACCESS_TOKEN (access_token) and LINKEDIN_PERSON_URN (sub) in your .env file.

Setup Supabase

Supabase is required for storing images found/generated by the agent.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言