Twitter is a constantly evolving platform, nominally you can find everything you need to create a bot on their platform page, but that information is subject to change.
Once installed, you will need to do steps 2-7 if you have not already. It helps to have your development environment and the Twitter for Developers page open at the same time.
Visit Twitter Developer Access Page and apply for a developer account to access the Twitter APIs.
Visit Twitter Developer Portal and create a new app.
- fill out form and specify url where your webhook endpoint will be available
Navigate to your app and then Permission and edit the permission to allow read, write and Direct Message
.
Navigate to your app and then Keys and Tokens to generate comsumer api keys as well as an access token and secret.
Copy this all keys and tokens, you'll need it when running your bot.
Navigate to the dev environments page of your Twitter developer account to set up an account activity dev environment.
Copy the label of the environment, you'll need it when running your bot.
Run your application with your environment variables set:
TWITTER_CONSUMER_KEY
- Your Consumer Key (required)TWITTER_CONSUMER_SECRET
- Your Consumer Secret (required)TWITTER_TOKEN
- Your Access Token (required)TWITTER_TOKEN_SECRET
- Your Access Token Secret (required)TWITTER_WEBHOOK_ENV
- Your Development Environment Label (required)
If your application has been configured correctly, you will be able to subscribe to the account activity of your bot account and send tweets and messages in his name. Congratulations!