A screenshot showing a tweet with an image and highlighting the code with alternative text.

Twitter bots and accessibility

Twitter’s engineers are doing their best to make the site accessible for everyone, but there are few areas in which they need our help. The following tips are useful both to you as a Twitter user and a Twitter bot creator.

Add image descriptions

When you upload an image to your tweet, you have an option to add a description that will be used by screen readers and thus making it possible for people who can’t see the image to get an idea what’s in it.

And when you make a Twitter bot that posts or generates images, you can use the Twitter API to do the same. Let me show you how.

The endpoint we’ll be using is media/metadata/create, check out the documentation for it here.

In short, after you upload an image, you can reference its ID and pass it to this endpoint together with an alt_text object that contains the description.

You can see the full code on GitHub, here’s what the relevant part looks like:

T.post('media/upload', {media_data: imageData}, (err, data, response) => {
    /* First we upload the image. */
    if (err){
        console.log('error:', err);
    } else {
        const image = data;
        /* Now we can add image description. */
        T.post('media/metadata/create', {
            media_id: data.media_id_string,
            alt_text: {
                text: 'Describe the image'
        }, (err, data, response) => {
            /* And finally, post a tweet with the image. */
            T.post('statuses/update', {
                // status: 'Optional tweet text.',
                media_ids: new Array(image.media_id_string)
            }, (err, data, response) => {
                if (err){
                    console.log('error:', err);

It’s a pretty easy and straightforward way to make sure everyone gets to enjoy your bot.

For some pointers on how to write a good image description, you can read this article from Harvard University.

Properly capitalize hashtags

If your bot uses hashtags, another good practice is to capitalize the first letter of each word. So instead #generativeart you should use #GenerativeArt. This is useful for screen readers, but also helps folks with dyslexia or cognitive disabilities.

Don’t use special characters that look like letters

When you use characters that look like letters, for example 𝖃 instead of the letter X, screen readers read the full name of such symbols, in our example that would be “Mathematical Bold Fraktur Capital X”.

Watch the video below to get a full sense of what the experience is like.

If you have any more tips, feel free to share them via email or Twitter DM!

More tutorials

A tinted collage of screenshots of various dataviz Twitter bots.

💻 Browse all