.gitignore | ||
index.mjs | ||
package-lock.json | ||
package.json | ||
Procfile | ||
README.md |
Sarcastic Twitter Bot
This bot reluctantly answer with sarcastic responses. Uses OpenAI's GPT-3 API to generate the comments. Hosted on Heroku, and uses offcial Twitter SDK to interact with Twitter.
Note: Right now, the bot is not deployed because Heroku removed its free tier and I can't find any other alternative that supports running a bot in the background. If you find one, connect me on Twitter roh1tkumar
Note: mention @bot_witty
in a tweet or under a tweet like below example.
Getting Stated
Clone the repository
$ git clone https://github.com/rohit1kumar/sarcastic-bot.git
Install dependencies
$ cd sarcastic-bot
$ npm install
Add environment variables
-
Visit OpenAI and get your API key
-
Visit Twitter and get get your API keys and tokens.
-
Create a
.env
file in the root directory$ cp .env.example .env $ nano .env
-
Now fill the corresponding values in the
.env
fileTWITTER_BEARER_TOKEN= TWITTER_API_KEY= TWITTER_API_SECRET_KEY= TWITTER_ACCESS_TOKEN= TWITTER_ACCESS_TOKEN_SECRET= OPENAI_API_KEY= BOT_USERNAME=
Note: Use the same bot username whose API key and token are being used.
Run the bot
$ npm start
I have used another library to post the tweet because the official Twitter SDK was not working for me, got some error which I was not able to resolve, hence I used twit. If you are able to resolve the issue, please feel free to open a PR.