Skip to content

One‐Time Setup to enable Threads

Elisa edited this page Nov 6, 2024 · 5 revisions

These steps only need to be completed once to set up the requirements to add Threads bots.

1. Set Up a Facebook Developer Account and Create an App

To access the Threads API, you need a Facebook Developer Account and a Facebook App configured with the appropriate use case.

  1. Create a Facebook Developer Account: If you don’t have one, go to Facebook for Developers and sign up.
  2. Create a New App:
    • Go to My Apps > Create App (or click here).
    • Select "Access the Threads API" as the primary use case for this app.
    • Complete the app creation process, providing basic details as prompted.
  3. Customize access to the Threads API:
    • From your app’s Dashboard, go to the left navigation bar and select Uses cases.
    • Click the Customize button next to the Access the Threads API use case.
    • In the Permissions tab, enable the following permissions:
      • threads_basic: For basic access to Threads.
      • threads_content_publish: For publishing content on Threads.
    • In the Settings tab, set the Redirect Callback URLs to <DJANGO_BASE_URL>/threads_callback (in prod https://bots.law/threads_callback). Do not forget to press enter after typing the URL since the text box accepts multiple inputs, otherwise it won't be saved.
  4. Get the App Credentials:
    • In the Settings > Basic section of your app, note down the Threads App ID and Threads App secret. You’ll need these to fetch the access token for Threads.

2. Configure Environment Variables

In the .env file, set the following variables:

THREADS_APP_ID="YOUR_APP_ID"
THREADS_APP_SECRET="YOUR_APP_SECRET"
THREADS_CALLBACK_URL="DJANGO_BASE_URL/threads_callback"  # URL that points to the threads_callback view

3. Configure AWS S3 for Image Storage

  • Make sure the bots.law S3 bucket allows the actions s3:PutObject, s3:GetObject and s3:PutObjectAcl for the AWS account used.
  • Make sure the bucket also allows the s3:GetObject action for everyone.
  • For reference, this policy has the minimum statements required for the integration to work (authenticated user can put objects in the bucket, and everyone can read them)
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::<AWS_ACCOUNT_ID>:user/<USER>"
            },
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:PutObjectAcl"
            ],
            "Resource": "arn:aws:s3:::<BUCKET_NAME>/*"
        },
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::<BUCKET_NAME>/*"
        }
    ]
}

After completing these steps, you can now proceed to create new Threads channels.

Clone this wiki locally