A Twitter bot which quote-tweets tweets without alt text

Overview

alt-alert-twitter-bot

A Twitter bot engine which quote-tweets tweets without alt text. Originally used for @UKGovAltBot, @UKCouncilAltBot and @USGovAltBot Screenshot of a tweet from UK Gov Alt Bot, quote-tweeting Rishi Sunak. Tweet text: This tweet from Rishi Sunak contains an image without alt text. Alt text is important for blind, partially sighted and neurodivergent people who use screen readers. More info: link to Civil Service alt text guidance

Blind, visually impaired and neurodivergent people often use screen reader software to help them use websites and apps. Screen readers rely on alt text to describe images, but if people don't provide alt text those images aren't accessible to people using screen readers.

This engine powers bots which find images posted by users the bot is following. If they don't have alt text the bot quote-tweets them, pointing the tweet's author to guidance on how to use alt text. You can power multiple bots with a single instance of the engine.

Getting started

Register a Twitter account for the bot

Before you do anything else, you'll need to sign up for a Twitter account for your bot.

Add 'Automated by' label

Once the bot account is registered, you should add an 'Automated by' label to it.

Screenshot of Twitter account information for UK Gov Alt Bot. There's a robot face icon with the text 'automated by @MattEason'

To add this label:

  1. Go to your account settings
  2. Select "Account information"
  3. Select "Your account"
  4. Select "Automation" at the bottom
  5. Select "Set up account automation"
  6. Enter your main Twitter username which runs your bot account
  7. Enter the password for your main Twitter account

Sign up for a developer Twitter account

You need a developer account to use the APIs. I recommend you do this with your main Twitter account rather than the bot account, especially if you're planning to run multiple bots.

Sign up from the Twitter Developer Platform homepage.

After you've signed up, you'll be asked to create a project, then an app. Go through these steps. The app name you choose will be shown on your tweets where you'd usually see 'Twitter for iOS' or 'Twitter for Android'

Once your app has been created, you'll be shown an API Key and an API Key Secret. Copy these now and keep them safe - you'll need them later.

You'll now have access to the v2 API. Unfortunately we need access to v1.1, because the endpoint the bot relies on (statuses/home_timeline) isn't in v2 yet.

To get access to v1.1, you'll need to apply for 'elevated access'. Select your project from the left-hand menu. You should see the following option:

Do you need Elevated access for your Project? Apply button

You'll have to fill in a bunch of boxes about your 'intended use'. Here's some suggested text for each part:

Describe how you plan to use Twitter data and/or APIs

"I'm developing a bot which follows [TYPE OF ACCOUNTS YOU'RE PLANNING TO FOLLOW] to check whether the images they're tweeting are accessible to blind and low-vision users. This was inspired by your recent roll-out of the ALT badge so that users can see which images have alt text."

Are you planning to analyze Twitter data?

Select 'Yes'

"Using the 'statuses/home_timeline' v1.1 API endpoint the bot analyses every tweet from [TYPE OF ACCOUNTS YOU'RE PLANNING TO FOLLOW] and looks for images included in the tweet. The bot determines whether the images in the tweet all have alt text by looking at the 'ext_alt_text' property for each image. Using the v1.1 API is necessary because v2 doesn't have an equivalent to the home_timeline endpoint and the list endpoints don't allow you to filter out things like replies and retweets."

Will your App use Tweet, Retweet, Like, Follow, or Direct Message functionality?

Select 'Yes'

"If an image doesn't have alt text, the bot will quote-tweet the original tweet to highlight that it doesn't have alt text. This uses the 'statuses/update' endpoint. This is the only interaction the bot will have."

Do you plan to display Tweets or aggregate data about Twitter content outside Twitter?

Select 'No'

Will your product, service, or analysis make Twitter content or derived information available to a government entity?

Select 'No'

And now we wait

After you've submitted your application, you may need to wait a few days for it to be approved.

Follow accounts

Your bot will only quote-tweet accounts that it's following, so go and follow those accounts while you wait for your API access to be approved. Following is rate-limited and you can only follow 400 accounts a day, so take it steady.

Authenticate your bot

You'll need to authorise your app to post on behalf of your bot's Twitter account. You'll need a REST client such as Insomnia or Postman

Step 1 - Get an OAuth token

Make a POST request to https://api.twitter.com/oauth/request_token?x_auth_access_type=write. You'll need to use OAuth 1 authentication. The Consumer Key and Consumer Key Secret are the API Key and API Key Secret you got when you were setting up your Twitter app.

Screenshot of Insomnia REST client showing a request to the Twitter request token endpoint

In the response, you'll get an oauth_token and an oauth_token_secret. Copy these somewhere safe.

Step 2 - Go to the authentication URL

Make sure you're signed into Twitter with your bot account, then go to https://api.twitter.com/oauth/authenticate?oauth_token=TOKEN, replacing TOKEN with the oauth_token from the last step.

You'll see an authorisation screen. Click the blue 'Authorize app' button. You'll see a seven-digit PIN. Copy this somewhere safe.

Step 3 - Get an access token and access token secret

Go back to your REST client and make a POST request to https://api.twitter.com/oauth/access_token?oauth_verifier=PIN&oauth_token=TOKEN, replacing PIN with the PIN from step 2 and TOKEN with the oauth_token from step 1.

In the response, you'll get a different oauth_token and oauth_token_secret to step 1. These are the Access Token and Access Token Secret you'll need for your bot. Copy them somewhere safe.

Configure the bot

Clone this repo then copy config.json.sample to config.json. In config.json, set the following values:

  • consumerKey: The API Key from when you set up the app in the Twitter dev dashboard
  • consumerKeySecret: The API Key Secret from when you set up the app in the Twitter dev dashboard
  • screenName: Your bot's Twitter username, without the @
  • accessTokenKey: The Access Token from step 3 above
  • accessTokenSecret: The Access Token Secret from step 3 above
  • infoUrl: This is the 'more info' link that will be included in your bot's tweets. The default is the Twitter guidance on adding alt text. You might want to change this if there's more specific guidance for your intended audience.

If you want to run multiple bots you can add more entries to the botAccounts array. You'll need to follow the steps above to register a Twitter account and authenticate for each bot.

Install dependencies

Install Node.js (I've tested with v16).

In the project directory (alt-alert-twitter-bot) run npm install

(Optional) Customise the tweet text

If you want to change the text the bot uses when it quote-tweets, you'll need to edit the status param in the retweet function in AltAlertBot.js.

This is useful if, for example, you want to localise the bot to a different language. Please keep the text polite and informative, and do not @mention the account you're retweeting. Unsolicited @mentions are forbidden in the API terms of use and your bot is likely to be shut down if you use them.

Run the bot

In the project directory (alt-alert-twitter-bot) run npm run start

Your bot(s) should start up and begin logging to the console:

Screenshot of text console showing logging lines from the alt bot

Running on a server

You'll probably want your bot running on a server to ensure it's always on. That's outside the scope of this README, but Googling for 'run node app on ${your cloud provider of choice}' should help.

License and credit

This project is licenced under the MIT License. An acknowledgement on your bot's Twitter profile is appreciated but not necessary.

If you'd like to, you can support me on Ko-Fi:

Buy Me a Coffee at ko-fi.com

Bots powered by this project

As well as the bots I run - @UKGovAltBot, @UKCouncilAltBot and @USGovAltBot - the following bots are also using this engine:

You might also like...

Ini Adalah Tools Bot WhatsApp,Pengodean Ulang Dari Sc Bot Kanna Bot

Ini Adalah Tools Bot WhatsApp,Pengodean Ulang Dari Sc Bot Kanna Bot

Node Modules Belum Selesai Unduh File Bot Lengkap Node Modules Click Here Lord Bot FOR DEPLOY HEROKU USER Instal Buildpack heroku/nodejs https://githu

Jul 1, 2022

This bot can raise your mood. This bot send joke often our channel for users. Sometimes bot don't work because we have not server for this project...)

This bot can raise your mood. This bot send joke often our channel for users. Sometimes bot don't work because we have not server for this project...)

Hi, welcome to send-joke-bot telegram bot project 🤖 What can do this bot ? This bot can raise your mood. This bot send joke often our channel for use

Sep 26, 2022

Discord.js ticket bot with buttons and without DB!

Ticket Bot Star (Please) How to use? Download the repo, create a .env file, and add your token into it. You need to change guildOnly to your guild id

Nov 17, 2022

An Easy to use and advanced working multiguild Waitingroom Bot written in discord.js v13 without any extra modules.

An Easy to use and advanced working multiguild Waitingroom Bot written in discord.js v13 without any extra modules.

Multiguild-Waitingroom-v13 An Easy to use and advanced working multiguild Waitingroom Bot written in discord.js v13 without any extra modules. It is m

Dec 11, 2022

a Node.js boilerplate to start creating your telegram bot without too much configuration at the beginning

node-telegram-bot-starter-pack How to use clone the repo run npm install run cp .env.example .env and replace the variables with your data define your

Sep 7, 2022

A Discord.js Music Bot, which connects via Lavalink and erela.js

A Discord.js Music Bot, which connects via Lavalink and erela.js

Discord.js Lavalink Music Bot using erela.js A Advance Discord Music Bot Like Hydra Erela.js docs Note this Discord Bot Repository is the Same as for

Dec 9, 2022

An efficient package, which syncs ratelimits of your Discord Bot on all Machines/Clusters.

An efficient package, which syncs ratelimits of your Discord Bot on all Machines/Clusters.

Discord-cross-ratelimit An efficient package, which syncs ratelimits of your Discord Bot on all Machines/Clusters. Why? When Sharding/Scaling your Bot

Oct 23, 2022

A simple bot for twitch, which has a silly AI in places. The library "cleverbot-free" is used for AI.

A simple bot for twitch, which has a silly AI in places. The library

AITwitchChat A simple bot for twitch, which has a silly AI in places. The library "cleverbot-free" is used for AI. Requiments tmi.js Node.js 16.6.0 or

Dec 7, 2022

This is Kesha bot which is made for fun, to show off my appreciate to Kesha and her work

Kesha bot What is this? This is Kesha bot which is made for fun, to show off my appreciate to Kesha and her work What Kesha bot can do it is still und

Dec 15, 2022
Owner
Matt Eason
Matt Eason
ð“„¿ CrowBot Remade - It's a multipurpose bot which is a remade of a py discord bot which is selled for 5e but this is in js !

CrowBot Remade - It's a multipurpose bot which is a remade of a py discord bot which is selled for 5e but this is in js ! CrowBot Remade is in french

baby 37 Dec 31, 2022
A multipurpose bot, a clan bot, a all in one bot. The one bot u need for ur server originally made as Milrato discord Bot and by Tomato6966.

Public Bot and Support Server! Invite the Public Version of this Bot so you don't need to host it by yourself or join my Discord server to get a custo

Tomato6966 472 Dec 25, 2022
It is a discord bot bot which can play lofi song in different language 24/7. It has premium system and cool embed looks with buttons. It can play youtube songs, playlists. This bot code was made by Supreme#2401. It uses djs V12

Lofi-Radio-Music-Bot It is a discord bot bot which can play lofi song in different language 24/7. It has premium system and cool embed looks with butt

Diwas Atreya 89 Jan 2, 2023
New base bot WhatsApp 🈴 bukan self bot lagi atau buka bot yang bisa di pakai oleh bot sendiri 😎

Installation • Thanks to • Donate Official Group Bot • Settings Instalasi Heroku Buildpack Click the deploy icon below ! > heroku/nodejs > https://g

zeeone 27 Feb 9, 2022
Gitlift Discord Bot is a discord bot which is listening Discord Messages to reply with user gitlift profile and total contributions.

Remoklify - Gitlift Discord Bot Gitlift Discord Bot is a discord bot which is listening Discord Messages to reply with user gitlift profile and total

Remoklify 3 Mar 20, 2022
Advanced Music Bot It is an advance type of discord music bot which plays high quality of music with spotify

Advanced Music Bot It is an advance type of discord music bot which plays high quality of music with spotify, apple music support . You can save your songs and play it. It also has DJ mode system.

Diwas Atreya 65 Dec 25, 2022
A repo to learn Twitter API and Bot development.

Twitter Information Warfare Defence Twitter has grown from a niche service to a mass phenomenon, serving as a tool for everyday communication as well

Panacloud 11 May 6, 2022
Twitter Bot for DevOps Community!

DevOps Twitter Bot Twitter Bot for DevOps Community! What is DevOps Community? DevOps/SRE community is for those folks who are trying to learn or expl

Rohit Ghumare 28 Oct 17, 2022
A Twitter bot that feeds magical realism prompts into the Stable Diffusion AI image generator.

Illustrated Magical Realism Bot Follow the bot on Twitter Follow @ImagicalRealism to see the generated output. Technical details The Twitter API This

Jeff Posnick 6 Nov 17, 2022
Discord-Bot - You can use the discord bot codes that are updated in every video of the codes I use in the discord bot making series that I have published on my youtube channel.

Discord-Bot You can use the discord bot codes that are updated in every video of the codes I use in the discord bot making series that I have publishe

Umut Bayraktar 114 Jan 3, 2023