Skip to content

Commit

Permalink
fix: Update docs to include basic setup mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jan 9, 2025
1 parent 15fefc3 commit 14ab567
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 14 deletions.
77 changes: 67 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,28 @@ This repository contains an 'agent' which can take in a URL, and generate a Twit
### Prerequisites

To use this project, you'll need to have the following accounts/API keys:
#### Basic Setup

To use the Social Media Agent with a basic setup, you'll need the following:

- [Anthropic API](https://console.anthropic.com/) - General LLM
- [LangGraph CLI](https://langchain-ai.github.io/langgraph/cloud/reference/cli/) - Running the LangGraph server locally
- [FireCrawl API](https://www.firecrawl.dev/) - Web scraping
- [Arcade](https://www.arcade-ai.com/) - Social media authentication
- [GitHub API](https://github.com/settings/personal-access-tokens) - Reading GitHub content (optional, if you do not plan on giving it any GitHub URLs)
- [LinkedIn Developer Account](https://developer.linkedin.com/) - Posting to LinkedIn (optional)

Running in basic setup mode will lack the following features:

- Image selection & uploads
- Posting to LinkedIn
- Ingesting data from a Slack channel
- Validating & generating content from YouTube videos

#### Full Setup

<details>
<summary>To use all of the features of the Social Media Agent, you'll need the following:</summary>

- [Anthropic API](https://console.anthropic.com/) - General LLM
- [Google Vertex AI](https://cloud.google.com/vertex-ai) - For dealing with YouTube video content
Expand All @@ -24,6 +45,8 @@ To use this project, you'll need to have the following accounts/API keys:
- [Supabase](https://supabase.com/) - Storing images
- [Slack Developer Account](https://api.slack.com/apps) (optional) - ingesting data from a Slack channel

</details>

### Setup Instructions

#### Clone the repository:
Expand Down Expand Up @@ -57,8 +80,11 @@ cp .env.example .env
Once done, ensure you've added the following environment variables to your `.env` file:

- `ARCADE_API_KEY`
- `TWITTER_API_KEY`
- `TWITTER_API_KEY_SECRET`

##### Full Setup Instructions

<details>
<summary>Full Twitter Setup Instructions</summary>

Arcade does not yet support Twitter (X) API v1, which is required for uploading media to Twitter. To configure the Twitter API v1, you'll need to follow a few extra steps:

Expand All @@ -69,18 +95,19 @@ Arcade does not yet support Twitter (X) API v1, which is required for uploading
5. Run the `yarn start:auth` command to run the Twitter OAuth server. Open [http://localhost:3000](http://localhost:3000) in your browser, and click `Login with Twitter`.
6. After logging in, copy the user token, and user token secret that was logged to the terminal. Set these values as `TWITTER_USER_TOKEN` and `TWITTER_USER_TOKEN_SECRET` in your `.env` file.

</details>

#### Setup LinkedIn authentication:

To authorize posting on LinkedIn, you'll need to:
<details>
<summary>To authorize posting on LinkedIn, you'll need to:</summary>

1. Create a new LinkedIn developer account, and app [here](https://developer.linkedin.com/)
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:

<details>
<summary>Company Setup</summary>
<summary>If you plan on posting from company pages, you'll need to do the following:</summary>

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:

Expand Down Expand Up @@ -109,23 +136,50 @@ If you plan on posting from company pages, you'll need to do the following:
5. Run the `yarn start:auth` command to run the LinkedIn OAuth server. Open [http://localhost:3000](http://localhost:3000) in your browser, and click `Login with LinkedIn`.
6. 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.

</details>

#### Setup Supabase

Supabase is required for storing images found/generated by the agent. To setup Supabase, create an account and a new project.
Supabase is required for storing images found/generated by the agent. This step is not required for running the agent in basic setup mode.

<details>
<summary>To setup Supabase</summary>

Create an account and a new project.

Set the `SUPABASE_URL` and `SUPABASE_SERVICE_ROLE_KEY` environment variables to the values provided by Supabase.

Create a new storage bucket called `images`. Make sure the bucket is set to public to the image URLs are accessible. Also ensure the max upload size is set to at least 5MB inside the global project settings, and the bucket specific settings.

</details>

#### Setup Slack

Slack integration is optional, but recommended if you intend on using the `ingest_data` agent. This agent can be used in a cron job to fetch messages from a Slack channel, and call the `generate_post` graph for each message. We use this flow internally to have a single place for submitting relevant URLs to the agent, which are then turned into posts once daily.

To configure the Slack integration, you'll need to create a new Slack app and install it into your desired Slack workspace. Once installed, ensure it has access to the channel you want to ingest messages from. Finally, make sure the `SLACK_BOT_TOKEN` environment variable is set.
<details>
<summary>To configure the Slack integration</summary>

Create a new Slack app and install it into your desired Slack workspace.

Once installed, ensure it has access to the channel you want to ingest messages from.

Finally, make sure the `SLACK_BOT_TOKEN` environment variable is set in your `.env` file.

</details>

#### Setup GitHub

The GitHub API token is required to fetch details about GitHub repository URLs submitted to the agent. To get a GitHub API token, simply create a new fine grained token with the `Public Repositories (read-only)` scope at a minimum. If you intend on using this agent for private GitHub repositories, you'll need to give the token access to those repositories as well.
The GitHub API token is required to fetch details about GitHub repository URLs submitted to the agent. This is not required if you do not plan on sending GitHub URLs to the agent.

<details>
<summary>To configure the GitHub integration</summary>

To get a GitHub API token, create a new fine grained token with the `Public Repositories (read-only)` scope at a minimum. If you intend on using this agent for private GitHub repositories, you'll need to give the token access to those repositories as well.

Ensure this is set as `GITHUB_TOKEN` in your `.env` file.

</details>

#### Setup LangGraph CLI

Expand Down Expand Up @@ -156,6 +210,9 @@ Before running, ensure you have the following environment variables set:

- `TWITTER_USER_ID` & `LINKEDIN_USER_ID` - The email address/username of the Twitter & LinkedIn account you'd like to have the agent use. (only one of these must be set). Optionally, you can pass these as configurable fields by editing the [`generate-demo-post.ts`](./scripts/generate-demo-post.ts) script.
- `LANGGRAPH_API_URL` - The URL of the local LangGraph server. **not** required if you passed `--port 54367` when running `langgraph up`.
- `USE_ARCADE_AUTH` - This should be enabled if you're running the agent in basic setup mode, or if running in full setup mode and want to use Arcade for reading Tweets (it'll still use your own Twitter API for uploading media).

If you do not want to run the agent in basic setup mode, make sure you update the script to pass `false` for the text only mode configurable field.

This will run the [`generate-demo-post.ts`](./scripts/generate-demo-post.ts) script, which generates a demo post on the [Open Canvas](https://github.com/langchain-ai/open-canvas) project.

Expand Down
6 changes: 2 additions & 4 deletions scripts/generate-demo-post.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import "dotenv/config";
import { Client } from "@langchain/langgraph-sdk";
// import {
// LINKEDIN_USER_ID,
// TWITTER_USER_ID,
// } from "../src/agents/generate-post/constants.js";
import { TEXT_ONLY_MODE } from "../src/agents/generate-post/constants.js";

/**
* Generate a post based on the Open Canvas project.
Expand All @@ -27,6 +24,7 @@ async function invokeGraph() {
// By default, the graph will read these values from the environment
// [TWITTER_USER_ID]: process.env.TWITTER_USER_ID,
// [LINKEDIN_USER_ID]: process.env.LINKEDIN_USER_ID,
[TEXT_ONLY_MODE]: true,
},
},
});
Expand Down

0 comments on commit 14ab567

Please sign in to comment.