How to Quickly Append Your Bot Profiles to Add a Label to Indicate They are Bots
Tags: twitter, showdev, bots, tutorial
Published: 2020-03-27 23:02:03

---
title: How to Quickly Append Your Bot Profiles to Add a Label to Indicate They are Bots
published: true
description: If you are creating Twitter bots and want to ensure your bots are in compliance with the new labeling requirements in our updated [guidelines](https://blog.twitter.com/developer/en_us/topics/community/2020/twitter_developer_policy_update.html), we’ve created a Python script to help you quickly add a label to your bots. 
tags: #Twitter #Showdev #bots #tutorial
---
_This tutorial was [originally posted to the Twitter developer blog](https://blog.twitter.com/developer/en_us/topics/tips/2020/how-to-quickly-update-your-bot-profile-bio.html)._

Recently we launched a [new Developer Policy](https://blog.twitter.com/developer/en_us/topics/community/2020/twitter_developer_policy_update.html) that has updated rules for the labeling of bots. If you are creating Twitter bots and want to ensure your bots are in compliance with the new labeling requirement, we’ve created a [Python script](https://github.com/twitterdev/bot-profile-append) to help you quickly add a label to your bots.

This script adds “#TwitterBot created by @handle” to the end of a profile bio. 

My current profile is as follows:
Developer Advocate @Twitter. Python programmer. Noted thought leader on vegan snacks. Makes music as Messica Arson. 

After I’d run this script, my profile would look like this:
Developer Advocate @Twitter. Python programmer. Noted thought leader on vegan snacks. Makes music as Messica Arson. #TwitterBot created by @JessicaGarson

To use this script you will need to have [Python 3](https://www.python.org/downloads/) installed on your machine. This script uses [`tweepy`](https://www.tweepy.org/), one of many open-source libraries built by the Twitter developer community. You will need to have this package installed.

You can run the following command in your terminal to install this package. In order to use `pip`, you will need to [install `pip` first](https://pip.pypa.io/en/stable/installing/).

```bash
pip install tweepy
```
To get started with this script you will need to clone this repository.

```bash
git clone https://github.com/twitterdev/bot-profile-append.git
```

From here, you will need to edit the configuration file that is in the repository as `secrets.yaml`. This file contains your `consumer key`, `consumer secret`, `access token`, `token secret`, and `user id`. For more information about locating your keys and tokens check out our [documentation on the subject](https://developer.twitter.com/en/docs/basics/apps/overview). You are going to want to make sure you add this file to your `.gitignore` before you push it to GitHub. For more information about working with a `.gitignore` file [check out this page](https://help.github.com/en/articles/ignoring-files). You also might want to [review our guide on keeping tokens secure](https://developer.twitter.com/en/docs/basics/authentication/guides/securing-keys-and-tokens).

You will need to replace the x’s with your own credentials in the `secrets.yaml`. You will also need to just update the configuration file to the number of bots you have. Keep in mind that our policies only allow you to have 10 applications associated with a developer account. You will also need to add your Twitter handle without the @ symbol to the admin section next to the key `handle`.

Your secrets.yaml should look similar to this example:

```yaml
admin:
  handle: "yourhandle"
bots:
  bot1:
    CONSUMER_KEY: "xxxxxxxxxxxxxxx"
    CONSUMER_SECRET: "xxxxxxxxxxxxxxx"
    ACCESS_TOKEN: "xxxxxxxxxxxxxxx"
    TOKEN_SECRET: "xxxxxxxxxxxxxxx"
    USER_ID: "xxxxxxxxxxxxxxx"
  bot2:
    CONSUMER_KEY: "xxxxxxxxxxxxxxx"
    CONSUMER_SECRET: "xxxxxxxxxxxxxxx"
    ACCESS_TOKEN: "xxxxxxxxxxxxxxx"
    TOKEN_SECRET: "xxxxxxxxxxxxxxx"
    USER_ID: "xxxxxxxxxxxxxxx"
  bot3:
    CONSUMER_KEY: "xxxxxxxxxxxxxxx"
    CONSUMER_SECRET: "xxxxxxxxxxxxxxx"
    ACCESS_TOKEN: "xxxxxxxxxxxxxxx"
    TOKEN_SECRET: "xxxxxxxxxxxxxxx"
    USER_ID: "xxxxxxxxxxxxxxx"
  bot4:
    CONSUMER_KEY: "xxxxxxxxxxxxxxx"
    CONSUMER_SECRET: "xxxxxxxxxxxxxxx"
    ACCESS_TOKEN: "xxxxxxxxxxxxxxx"
    TOKEN_SECRET: "xxxxxxxxxxxxxxx"
    USER_ID: "xxxxxxxxxxxxxxx"
  bot5:
    CONSUMER_KEY: "xxxxxxxxxxxxxxx"
    CONSUMER_SECRET: "xxxxxxxxxxxxxxx"
    ACCESS_TOKEN: "xxxxxxxxxxxxxxx"
    TOKEN_SECRET: "xxxxxxxxxxxxxxx"
    USER_ID: "xxxxxxxxxxxxxxx"
  bot6:
    CONSUMER_KEY: "xxxxxxxxxxxxxxx"
    CONSUMER_SECRET: "xxxxxxxxxxxxxxx"
    ACCESS_TOKEN: "xxxxxxxxxxxxxxx"
    TOKEN_SECRET: "xxxxxxxxxxxxxxx"
    USER_ID: "xxxxxxxxxxxxxxx"
  bot7:
    CONSUMER_KEY: "xxxxxxxxxxxxxxx"
    CONSUMER_SECRET: "xxxxxxxxxxxxxxx"
    ACCESS_TOKEN: "xxxxxxxxxxxxxxx"
    TOKEN_SECRET: "xxxxxxxxxxxxxxx"
    USER_ID: "xxxxxxxxxxxxxxx"
  bot8:
    CONSUMER_KEY: "xxxxxxxxxxxxxxx"
    CONSUMER_SECRET: "xxxxxxxxxxxxxxx"
    ACCESS_TOKEN: "xxxxxxxxxxxxxxx"
    TOKEN_SECRET: "xxxxxxxxxxxxxxx"
    USER_ID: "xxxxxxxxxxxxxxx"
  bot9:
    CONSUMER_KEY: "xxxxxxxxxxxxxxx"
    CONSUMER_SECRET: "xxxxxxxxxxxxxxx"
    ACCESS_TOKEN: "xxxxxxxxxxxxxxx"
    TOKEN_SECRET: "xxxxxxxxxxxxxxx"
    USER_ID: "xxxxxxxxxxxxxxx"
  bot10:
    CONSUMER_KEY: "xxxxxxxxxxxxxxx"
    CONSUMER_SECRET: "xxxxxxxxxxxxxxx"
    ACCESS_TOKEN: "xxxxxxxxxxxxxxx"
    TOKEN_SECRET: "xxxxxxxxxxxxxxx"
    USER_ID: "xxxxxxxxxxxxxxx"
```

After you’ve set up your configuration file you should be ready to run your script. You will first need to be in the directory you cloned and run the script.

```bash
cd bot-profile-append.py
python bot-profile-append.py
```

If one of your accounts is nearing or at the 160 character limit you will see the following error:

```
[{'code': 120, 'message': 'Account update failed: Description is too long (maximum is 160 characters).'}]
```

At this point, you will see that your bots should now have #TwitterBot created by @[your Twitter handle] appended at the end of their profile. While creating bots with the Twitter API, be sure to take a look at the [Developer Agreement](https://developer.twitter.com/en/developer-terms/agreement-and-policy.html) or your Master Licensing Agreement or Order (if applicable), [Automation Rules](https://help.twitter.com/en/rules-and-policies/twitter-automation), [Display Requirements](https://developer.twitter.com/en/developer-terms/display-requirements.html), and the [Twitter Rules](https://help.twitter.com/en/rules-and-policies/twitter-rules) and ensure what you are building is in accordance with them.

I used several libraries and tools beyond the Twitter API to create this code sample, but you may have different needs and requirements and should evaluate whether those tools are right for you. This script is just one method you can use to make sure you are labeling your bots accordingly. And please share your examples of this code in action with us by Tweeting at @TwitterDev.