Skip to content

Configuring the bot

Carlos Bello edited this page Jan 22, 2023 · 39 revisions

Now that you have downloaded and installed the bot you can start configuring your bot.

First, we will set up the environment file, which you will use to configure the bot to your needs.

Environment File and Environment Variables

- Linux

CLICK HERE IF YOU ARE RUNNING THE BOT ON LINUX

For Linux, the bot is configured through environment variables that can be set using a file called ecosystem.json that the bot reads when it starts.

The content of ecosystem.json file:

{
    "apps": [
        {
            "name": "tf2autobot",
            "script": "dist/app.js",
            "exec_mode": "fork",
            "shutdown_with_message": false,
            "max_memory_restart": "1500M",
            "kill_retry_time": 30000,
            "kill_timeout": 60000,
            "out_file": "NULL",
            "error_file": "NULL",
            "env": {
                "NODE_ENV": "production",

                "STEAM_ACCOUNT_NAME": "",
                "STEAM_PASSWORD": "",
                "STEAM_SHARED_SECRET": "",
                "STEAM_IDENTITY_SECRET": "",

                "BPTF_ACCESS_TOKEN": "",
                "BPTF_API_KEY": "",

                "USERAGENT_HEADER_CUSTOM": "",

                "MPTF_API_KEY": "",
                "DISCORD_BOT_TOKEN": "",

                "ADMINS": [
                    { "steam": "<your steamid 64>", "discord": null }
                ],
                "KEEP": ["<steamid of person to keep in friendslist>"],
                "ITEM_STATS_WHITELIST": [],
                "GROUPS": ["103582791469033930"],
                "ALERTS": ["trade", "version"],

                "ENABLE_SOCKET": true,
                "CUSTOM_PRICER_URL": "",
                "CUSTOM_PRICER_API_TOKEN": "",

                "RUN_ON_ANDROID": false,

                "SKIP_BPTF_TRADEOFFERURL": true,
                "SKIP_UPDATE_PROFILE_SETTINGS": true,

                "TIMEZONE": "Europe/London",
                "CUSTOM_TIME_FORMAT": "MMMM Do YYYY, HH:mm:ss ZZ",
                "TIME_ADDITIONAL_NOTES": "",

                "DEBUG": true,
                "DEBUG_FILE": true,
                "DEBUG_SCHEMA": false,
                "ENABLE_SAVE_LOG_FILE": true,

                "ENABLE_HTTP_API": false,
                "HTTP_API_PORT": 3001
            }
        }
    ]
}

Modify the template.ecosystem.json file found in your tf2autobot/ folder, renaming it to ecosystem.json. This file will be the file you edit when you want to configure your bot, using the below variables.

ECOSYSTEM.JSON FOR TWO BOTS
{
    "apps": [
        {
            "name": "tf2autobot-1",
            "script": "dist/app.js",
            "exec_mode": "fork",
            "shutdown_with_message": false,
            "max_memory_restart": "1500M",
            "kill_retry_time": 30000,
            "kill_timeout": 60000,
            "out_file": "NULL",
            "error_file": "NULL",
            "env": {
                "NODE_ENV": "production",

                "STEAM_ACCOUNT_NAME": "",
                "STEAM_PASSWORD": "",
                "STEAM_SHARED_SECRET": "",
                "STEAM_IDENTITY_SECRET": "",

                "BPTF_ACCESS_TOKEN": "",
                "BPTF_API_KEY": "",

                "USERAGENT_HEADER_CUSTOM": "",

                "MPTF_API_KEY": "",
                "DISCORD_BOT_TOKEN": "",

                "ADMINS": [
                    { "steam": "<your steamid 64>", "discord": null }
                ],
                "KEEP": ["<steamid of person to keep in friendslist>"],
                "ITEM_STATS_WHITELIST": [],
                "GROUPS": ["103582791469033930"],
                "ALERTS": ["trade", "version"],

                "ENABLE_SOCKET": true,
                "CUSTOM_PRICER_URL": "",
                "CUSTOM_PRICER_API_TOKEN": "",

                "RUN_ON_ANDROID": false,

                "SKIP_BPTF_TRADEOFFERURL": true,
                "SKIP_UPDATE_PROFILE_SETTINGS": true,

                "TIMEZONE": "Europe/London",
                "CUSTOM_TIME_FORMAT": "MMMM Do YYYY, HH:mm:ss ZZ",
                "TIME_ADDITIONAL_NOTES": "",

                "DEBUG": true,
                "DEBUG_FILE": true,
                "DEBUG_SCHEMA": false,
                "ENABLE_SAVE_LOG_FILE": true,

                "ENABLE_HTTP_API": false,
                "HTTP_API_PORT": 3001
            }
        },
        {
            "name": "tf2autobot-2",
            "script": "dist/app.js",
            "exec_mode": "fork",
            "shutdown_with_message": false,
            "max_memory_restart": "1500M",
            "kill_retry_time": 30000,
            "kill_timeout": 60000,
            "out_file": "NULL",
            "error_file": "NULL",
            "env": {
                "NODE_ENV": "production",

                "STEAM_ACCOUNT_NAME": "",
                "STEAM_PASSWORD": "",
                "STEAM_SHARED_SECRET": "",
                "STEAM_IDENTITY_SECRET": "",

                "BPTF_ACCESS_TOKEN": "",
                "BPTF_API_KEY": "",

                "USERAGENT_HEADER_CUSTOM": "",

                "MPTF_API_KEY": "",
                "DISCORD_BOT_TOKEN": "",

                "ADMINS": [
                    { "steam": "<your steamid 64>", "discord": null }
                ],
                "KEEP": ["<steamid of person to keep in friendslist>"],
                "ITEM_STATS_WHITELIST": [],
                "GROUPS": ["103582791469033930"],
                "ALERTS": ["trade", "version"],

                "ENABLE_SOCKET": true,
                "CUSTOM_PRICER_URL": "",
                "CUSTOM_PRICER_API_TOKEN": "",

                "RUN_ON_ANDROID": false,

                "SKIP_BPTF_TRADEOFFERURL": true,
                "SKIP_UPDATE_PROFILE_SETTINGS": true,

                "TIMEZONE": "Europe/London",
                "CUSTOM_TIME_FORMAT": "MMMM Do YYYY, HH:mm:ss ZZ",
                "TIME_ADDITIONAL_NOTES": "",

                "DEBUG": true,
                "DEBUG_FILE": true,
                "DEBUG_SCHEMA": false,
                "ENABLE_SAVE_LOG_FILE": true,

                "ENABLE_HTTP_API": false,
                "HTTP_API_PORT": 3001
            }
        }
    ]
}
ECOSYSTEM.JSON FOR MORE THAN TWO BOTS

You should feel familiar with the layout of the ecosystem.json from the example of the ecosystem.json for two bots.

Every bot is an object inside your apps array. The bot's environment starts with a curly bracket and ends with one.

- Windows

CLICK HERE IF YOU ARE RUNNING THE BOT ON WINDOWS

For Windows, the bot is configured through environment variables that can be set using a file (.env) that the bot reads when it starts.

The content of the .env file:

NODE_ENV="production"

STEAM_ACCOUNT_NAME=""
STEAM_PASSWORD=""
STEAM_SHARED_SECRET=""
STEAM_IDENTITY_SECRET=""

BPTF_ACCESS_TOKEN=""
BPTF_API_KEY=""

ADMINS=["<your steamid 64>"]
KEEP=["<steamid of person to keep in friendslist>"]
ITEM_STATS_WHITELIST=[]
GROUPS=["103582791469033930"]
ALERTS=["trade", "version"]

ENABLE_SOCKET=true
CUSTOM_PRICER_URL=""
CUSTOM_PRICER_API_TOKEN=""

SKIP_BPTF_TRADEOFFERURL=true
SKIP_UPDATE_PROFILE_SETTINGS=true

TIMEZONE=""
CUSTOM_TIME_FORMAT=""
TIME_ADDITIONAL_NOTES=""

DEBUG=true
DEBUG_FILE=true

ENABLE_HTTP_API=false
HTTP_API_PORT=3001

Please ensure that you have file extension viewing enabled in your Windows settings prior to continuing (click here for more information).

Modify the template.env file found in your tf2autobot/ folder, renaming it to .env (yes, only a dot (.) and a word env). This file will be the file you edit when you want to configure your bot, using the below variables.

CLICK HERE IF YOU WANT TO RUN MULTIPLE BOTS ON WINDOWS

Running multiple bots on Windows is very simple. You just need to clone and build the bot again.

You can follow these instructions:

git clone https://github.com/TF2Autobot/tf2autobot.git <folderName>

Make sure to replace <folderName> with whatever you would like to call the folder, for example tf2autobot2

cd <folderName>

npm install

npm run build

Now all that is left to do is to configure your .env and options.json file.

Required Variables

To be able to start the bot, you need to set a few compulsory variables. All of the variables in this section must be set or your bot will not run!

If you have followed the Before You Start section of the guide, you should already have your STEAM_SHARED_SECRET and STEAM_IDENTITY_SECRET on-hand.

Bot Credentials

Variable Type Description
STEAM_ACCOUNT_NAME string The Steam account username of your bot account
STEAM_PASSWORD string The Steam account password of your bot account
STEAM_SHARED_SECRET string You can find this in the <yourBotSteamID>.maFile file inside the /SDA/maFiles/ folder. Open the file using notepad and search for your shared_secret. An example of what that may look like is "shared_secret": "agdgwegdgawfagxafagfkagusbuigiuefh==" .
STEAM_IDENTITY_SECRET string Same as above (but now search for identity_secret).

Question: Where can I obtain the above secrets?

Answer: You need to activate Steam Guard for your bot account using Steam Desktop Authenticator. This application can be set up on your desktop and does not need to be set up on the system running the bot. Once SDA is fully set up, all you will need to do is transfer the secrets as described above.

Backpack.tf User Token and API Key

If you have followed the Before You Start section of the guide, you should already have your BPTF_ACCESS_TOKEN and BPTF_API_KEY on-hand.

You are able to run your bot without the User Token and API Key initially. On the first run, your bot will print out your backpack.tf User Token and API Key. You'll need to copy and paste these into your ecosystem.json (on Linux) or .env file (on Windows). Please see this image for more information.

After obtaining your backpack.tf User Token and API Key, update the following variables in your configuration file:

Variable Type Description
BPTF_ACCESS_TOKEN string Your bot's backpack.tf User Token
BPTF_API_KEY string Your bot's backpack.tf API Key
USERAGENT_HEADER_CUSTOM string Custom client header that will be shown on backpack.tf listings. Format: "TF2Autobot - <custom here>".
USERAGENT_HEADER_SHOW_VERSION boolean Show bot version. Default is false. If set to true, it will be "TF2Autobot@v<version> - "

Question: Where can I obtain the above token/key if I am obtaining them manually from the backpack.tf?

Answer:

  • User Token: While logged into backpack.tf as your bot account go to https://backpack.tf/connections and click Show Token under "User Token".
  • API Key: While still logged into backpack.tf as your bot account go to https://backpack.tf/developer/apikey/view - fill in the following for the "site URL" http://localhost:4566/tasks and the following for "comments" Check if a user is banned on backpack.tf.

Marketplace.tf API Key

This is exclusively for Marketplace.tf selected sellers. The use of this API Key is to request a ban check (https://marketplace.tf/api/Bans/GetUserBan/v2) when the bot is receiving friend requests, and/or before accepting any trades.

Variable Type Description
MPTF_API_KEY string Your marketplace.tf API Key

**How to get your Marketplace.tf API Key?

Note: You can't get the API Key if you log in to the marketplace.tf as your bot account. Only get one from your own main account.

Discord interface

Discord interface integration. Credit to @RobotoLev.

Variable Type Description
DISCORD_BOT_TOKEN string Your Discord bot/application token, refer: Setting up Discord Interface.

Owners' Details and Other Required Variables

interface Admins {
    steam: string;
    discord?: string;
}
Variable Type Description
ADMINS Admins[] An Array of Admins Object containing the SteamID64 of your primary account (not your bot), and optionally your Discord ID. Any accounts in this list are designated as an admin/owner.
KEEP string[] Please include your own SteamID64 here. Any accounts in this will not be removed from the bot's friends list in the event that its friend's list is full.
ITEM_STATS_ WHITELIST string[] The SteamID64 of the people that you want to whitelist to use !itemstats command. By default, only IdiNium can use it on all bots (only !itemstats command, all other admin-only commands are not possible). Just leave it empty if you don't want to whitelist anyone, else, make sure the format is the same as in ADMINS or KEEP.
GROUPS string[] Default group is TF2Autobot. If you have a Steam group, find your group ID and paste it here. The bot will automatically invite new trade partners to all groups in this list (by group ID).
ALERTS string[] By default your bot will send a message/discord webhook every time a successful trade is made and send notification in Steam chat if new version has been released. To disable both, set to only ["none"]

Please ensure you fill in all of the above Environmental variables.

Additional info

In the templates, you can see the value for ADMINS and KEEP are "<your steamid 64>" and ["<steamid of person to keep in friendslist>"], respectively. Ensure that <your steamid 64> contains YOUR SteamID64, and that <steamid of person to keep in friendslist> contains the SteamID64 of anyone you don't want to be removed from the bot's friendslist.

ADMINS format

  • One admin without Discord:
"ADMINS": [
   { "steam": "76561198013127982" }
]

or

"ADMINS": [
   { "steam": "76561198013127982", "discord": null }
]
  • One admin with Discord:
"ADMINS": [
   { "steam": "76561198013127982", "discord": "527868979600031765" }
]
  • Multiple admins:
"ADMINS": [
   { "steam": "76561198013127982", "discord": "527868979600031765" },
   { "steam": "76561198077208792" }
]

Question: Where can I obtain a player's SteamID64?

Answer: You can find your SteamID64 by pasting your Steam Profile URL link to SteamRep.com. Please view the gif below for more information.

How to get SteamID64

Optional Variables

Alternative Inventory API Keys

Alternative inventory APIs are paid services that allow the bot to access inventories more reliably. For more details including how to set them up, see Alternative Inventory APIs.

Variable Type Default Description
STEAMSUPPLY_API_KEY string "" SteamSupply API key. See Alternative Inventory APIs
STEAMAPIS_API_KEY string "" SteamAPIs API key. See Alternative Inventory APIs

Custom Pricer Settings - only for advanced users

Custom Pricer Settings are for directing the bot at a price source other than prices.tf. Nothing needs to be set to use prices.tf. If you are using another price source refer to the alternative price source's documentation.

Leave these variables untouched if you don't know what you are doing.

Variable Type Default Description
ENABLE_SOCKET boolean true Read: #383
CUSTOM_PRICER_URL string "" Unless you have a reason to edit this property, you should keep it at default. This is unnecessary for prices.tf (the default price source).
CUSTOM_PRICER_API_TOKEN string "" Unless you have a reason to edit this property, you should keep it at default. This is unnecessary for prices.tf (the default price source).

Run on Android

Variable Type Default Description
RUN_ON_ANDROID boolean false Read: #1211

Bot Profile Settings

Variable Type Default Description
SKIP_BPTF_ TRADEOFFERURL boolean true By default, your bot will skip the step to set it's Steam Trade Offer URL on backpack.tf. You can set this to false and run the bot, and if there are any issues setting this URL, please manually do so here, and be sure to login using your bot's Steam account. If you've already set your Trade Offer URL on backpack.tf manually (as recommended in the guide), just leave this set to true.
SKIP_UPDATE_ PROFILE_SETTINGS boolean true If set to false, your bot will attempt to set all of your profile settings to public. This is just so that backpack.tf can load your bot inventory correctly. If you already set everything to the public, just leave this set to true.

Timezone Settings

The time settings listed here will be used in the !time command as well as in messages sent to trade partners if their offer needs to be reviewed.

Variable Type Default Description
TIMEZONE string Europe/London The timezone that you currently reside in. Please only use these Timezone Formats. For example, if you live in Malaysia, you can use the value Asia/Kuala_Lumpur. Or if you live in New York, you can use the value America/New_York.
CUSTOM_TIME_FORMAT string MMMM Do YYYY, HH:mm:ss ZZ Please refer to this article for more information on specifying a custom time format for your bot.
TIME_ADDITIONAL_NOTES string "" Optional additional notes when the bot shows your current time. Some examples are your active hours or who to contact if you are offline.

Debug Settings

Variable Type Default Description
DEBUG boolean true If set to true, the bot will log any errors that occur into the console.
DEBUG_FILE boolean true If set to true, the bot will log any errors that occur to a file. This file can be later be used to create a GitHub issue to report any issues to the developers.
ENABLE_SAVE_LOG_FILE boolean true Set to false if you don't want the bot to save log files, but before that, read this.

API

The bot can expose an HTTP server to check for availability/health or uptime.

By default is disabled, and you might turn it on in case you are running the bot with Docker and check periodically if the bot is up and running.

Keep in mind that if you run multiple instances and enable the HTTP API, you should use different HTTP_API_PORT values for each bot since no two bots can open the same port in the same network.

When running, you can access it from http://127.0.0.1:[HTTP_API_PORT]. Below you will also find the available paths for different functionalities.

Variable Type Default Description
ENABLE_HTTP_API boolean false Read: #413; Whether the API should be turned on.
HTTP_API_PORT number 3001 Defaults to a non-conflicting

Each of the following paths can be appended to the HTTP API URL.

Endpoint Description Response example
/health Check for health. Returns 200 OK if the bot is running. OK
/uptime Get the current bot uptime, in seconds. {"uptime": 3600}

Done?

Then the next step will be to run the bot for the first time (Windows | Linux) to get your options.json generated, and then you can proceed to configure your options.json file

Clone this wiki locally