Skip to main content

Twitter App Setup

Twitter channel with Chatwoot requires access to Twitter APIs. We are using Account Activity API. If you don't have access to Twitter Business APIs, apply for one at Twitter developer portal.

Once your application is approved, you will be able to add Twitter Apps and dev environments. If you have applied for a team account, you can invite more team members. You will have to set the following environment variables for the channel to work. We will describe what it means in the following sections.

TWITTER_APP_ID=
TWITTER_CONSUMER_KEY=
TWITTER_CONSUMER_SECRET=
TWITTER_ENVIRONMENT=

1. Twitter standalone App

One way to handle Twitter API is through a standalone app, which doesn't require the creation of a project to create an app,

Create a Twitter App

In Twitter Developer Portal, go to Projects & Apps Overview Console. Then, go to the "Standalone Apps" section. Then, click on the "Create App" button.

standalone

Provide an app name and click on "Next".

name-your-app

You will be able to see the API Key and API Secret Key in the next step. Save this information as it would not available again.

  • Use API Key as TWITTER_CONSUMER_KEY in Chatwoot.
  • Use API Secret Key as TWITTER_CONSUMER_SECRET in Chatwoot.
add-api-keys

Hooray! The app has been created. The next step is to enable "Sign in with Twitter" permission.

Complete profile information

Complete the application profile. See the "App Details" section as shown below for additional information. Then Update the name, logo and description. Finally, use the "APP ID" displayed in the screenshot as TWITTER_APP_ID in Chatwoot.

app-details

Select authentication settings

Chatwoot works with Twitter API OAuth 1.0. So select OAuth 1.0a from the authentication settings page.

app-oauth-info

Add app permissions

Head over to the "App Permissions" section by clicking the setup button above. Then, update the permission to "Read and Write and Direct Messages".

app-permission

Update general authentication settings

Add the callback url as {your_chatwoot_installation_url}/twitter/callback.

callback-url

Complete the rest of the details in the authentication settings and click on "Save". And it's ready to use. Use all the API keys in your setup.

2. Create Twitter API project

There is one more way to create a Twitter app. Instead of a standalone app, create a project and add the app to the project.

Add project details

Add project name, select project type, add a project description

Click on create project

create-project

Add project name

add-project-name

Select project type

select-project-type

Add project description

add-project-details

App setup

Once you setup the project, you move on to the app setup. Select the appropriate environment for your self-hosted app according to the status of your application. Please note this is not the same environment as we set up in chatwoot. We are going to see about TWITTER_ENVIRONMENT at a later point.

project-app-name

After this step, you should follow the similar step for an API key and secret in step 1, set the app name and go to the next step. You will get the API key and API secret keys. Save those keys.

  • Use API Key as TWITTER_CONSUMER_KEY in Chatwoot.
  • Use API Secret Key as TWITTER_CONSUMER_SECRET in Chatwoot.

PS: After you complete Step 1 or Step 2 (both steps are alternative to each other), move on to the below step to set up the dev environment.

Create a dev environment (required)

For the DMs and Tweets to work in realtime, you need to set up an "Account Activity API" dev environment. A Twitter development environment is required for all installations of Chatwoot.

URL: https://developer.twitter.com/en/account/environments

Head over to Products -> Premium -> Dev Environments. Click on Set up dev environment. You will be able to see a form as follows.

setup-dev-env

Provide a Dev Environment Label. This should be an alphanumeric string. Use the exact string as TWITTER_ENVIRONMENT in Chatwoot.

dev-env

Once you do this, you will be ready to use Twitter Channels. To connect your Twitter account, follow this guide.