Skip to main content

Introduction

To develop and host a Slack bot on Square Cloud, it’s essential to follow a structured sequence of configurations and prerequisites. This technical guide will cover the entire process, from initial setup to production deployment.

Prerequisites

  • Square Cloud Account: Register through the signup page using your email.
  • Active plan: Ensures dedicated resources and optimized performance for your application. Check our available plans and choose the most suitable for your needs.
This guide runs on the Node.js runtime or the Python runtime.

Create the project

To create a Slack bot, you will need an account and permissions to create apps on Slack. Create or access your account on Slack before following the next steps.

Bot application on Slack

  1. Go to the Slack API - Your Apps and click “Create New App”.
  2. Choose “From scratch”, give the app a name and select the workspace where you will install it.
  3. In the “Socket Mode” section, enable Socket Mode and generate an app-level token with the connections:write scope. Copy it (it starts with xapp-): this is your SLACK_APP_TOKEN.
  4. In the “OAuth & Permissions” section, add the scopes your bot needs (e.g. chat:write, app_mentions:read, commands), install the app to your workspace and copy the Bot User OAuth Token (it starts with xoxb-): this is your SLACK_BOT_TOKEN.
  5. In “Event Subscriptions”, enable events and subscribe to the app_mention bot event. In “Slash Commands”, create the /hello command. With Socket Mode enabled, neither asks for a Request URL.
Security: Never expose the app-level token or the Bot Token publicly. Treat them as sensitive credentials: the examples below read them from environment variables, never from your code.
With Socket Mode, the bot opens the connection to Slack itself, so it runs like any other bot: no public URL or port is needed. If you prefer Slack to send events over HTTP, see Use HTTP mode instead of Socket Mode.

Develop the bot

Use the tab for the language you choose. Both examples reply to mentions and to the /hello slash command.
  1. Make sure Node.js is installed.
  2. Initialize a project and install dependencies:
Terminal
  1. Create an index.js file with the following content:
index.js

Configure Square Cloud

Create a squarecloud.app file at the root of your project, next to your main file. It tells Square Cloud how to run your bot:
  • MAIN is the file Square Cloud runs, and MEMORY is the bot’s RAM in MB. Bots need at least 256 MB; 512 MB leaves room to grow.
  • AUTORESTART=true starts the bot again if it crashes. See how auto restart works.
  • There is no SUBDOMAIN: in Socket Mode, the bot needs no public URL.
See the configuration file reference for every field.

Set the tokens

Your code reads both tokens from the SLACK_BOT_TOKEN and SLACK_APP_TOKEN environment variables, so they never go into your files. Set them in one of these ways:
  • Dashboard: on the upload page, open Advanced configuration and add both variables. For a bot that is already deployed, add them on the application’s Environment Variables page and restart the bot.
  • CLI: right after you upload the bot (see Deploy and verify), set them with squarecloud app env set and restart the bot:
The bot reads its environment variables when it starts, so restart it after every change. See Environment variables for the other ways to manage them.

What goes in the ZIP

  • Your main file (index.js or app.py) and your other source files.
  • package.json or requirements.txt.
  • squarecloud.app.
Leave out node_modules, .venv and __pycache__: Square Cloud installs your dependencies when the bot starts.

Deploy and verify

Create the ZIP described above, then upload it:

Via dashboard

1

Access the Upload Page

Access the upload page and upload your project zip file.
2

Configure Your Environment

After uploading your zip, you will need to configure the name, main file or runtime environment and other settings for your project.
If you are uploading a web project, make sure to select “Web Publication” and set a subdomain to your project.
3

Deploy Your Project

Finally, click on the “Deploy” button to host your project on Square Cloud.
After deployment, you can monitor your project’s status and logs from the dashboard.
Uploading application to Square Cloud
4

Confirm Your App Is Live

Your first deploy usually takes less than a minute. In the dashboard, wait for your application status to show as running and check the logs for any startup errors.
If you deployed a website or API, open https://<your-subdomain>.squareweb.app in your browser: you should see your application responding. If you deployed a bot, send it a command to confirm it is online.
App not starting? See the Troubleshooting guide for the most common causes and fixes.

Via CLI

To use this method, your project needs a configuration file named squarecloud.app at its root. It tells Square Cloud how to run your application.

Configuration file guide

Learn how to create the squarecloud.app configuration file that defines your application’s environment.
1

Install the CLI

Install the Square Cloud CLI. If you already have it, run the same command to update it:
2

Log In

Run the command below. It opens your browser: approve the login there and the CLI is ready. There is no API key to copy. For scripts and CI, see CLI authentication.
3

Upload Your Project

From your project folder, run the command below. The CLI zips the current folder, leaving out what squarecloud.ignore lists, and uploads it:
To upload a zip you created yourself, pass it with --file:
4

Confirm Your App Is Live

Your first deploy usually takes less than a minute. Check your application status and logs directly from the terminal:
If you deployed a website or API, open https://<your-subdomain>.squareweb.app in your browser: you should see your application responding. If you deployed a bot, send it a command to confirm it is online.
App not starting? See the Troubleshooting guide for the most common causes and fixes.

Test the bot

  1. In the Slack app settings, under “OAuth & Permissions”, install the app to the workspace (if you haven’t already).
  2. Check the application logs in the Square Cloud dashboard for startup errors. With Socket Mode there is no Request URL to configure: the bot connects to Slack as soon as it starts.
  3. Invite the bot to a channel, then mention it or run the /hello command to validate responses.
Example install link (replace the client_id):

Common errors

You must provide an appToken when socketMode is set to true

Bolt for JavaScript stops at startup with this message when SLACK_APP_TOKEN is not set. Set the app-level token (the one that starts with xapp-) and restart the bot.

Either an env variable SLACK_BOT_TOKEN or token argument in the constructor is required

Bolt for Python stops at startup with this message when SLACK_BOT_TOKEN is not set. Set the Bot User OAuth Token (the one that starts with xoxb-) and restart the bot.

The bot doesn’t answer mentions

Check that the bot is a member of the channel, that “Event Subscriptions” subscribes to the app_mention bot event, and that you reinstalled the app after adding scopes.

Use HTTP mode instead of Socket Mode

Apps that use Socket Mode can’t be listed in the public Slack Marketplace. If you need Slack to send events over HTTP instead, run the bot as a web application:
  1. In the Slack app settings, disable Socket Mode and copy the Signing Secret (under “Basic Information”) into a SLACK_SIGNING_SECRET environment variable, set the same way as the tokens.
  2. Create the app with the signing secret instead of the app-level token, and listen on the port in the PORT environment variable:
Both servers listen on all network interfaces (0.0.0.0), which Square Cloud requires.
  1. Add a SUBDOMAIN to your configuration file (or select “Web Publication” and set a subdomain when uploading from the dashboard) so the bot gets a public URL. Web applications need at least MEMORY=512:
squarecloud.app
An application uploaded without a subdomain can’t get one later. If your bot already runs in Socket Mode, upload the HTTP version as a new application.
  1. In “Event Subscriptions” and in the /hello slash command, set the Request URL to https://<subdomain>.squareweb.app/slack/events.

Next steps

App won't start

Fix missing modules, memory errors and other startup failures.

Environment variables

Manage your bot’s tokens and other secrets.

Discord bot

Host a Discord bot next to your Slack bot.
For more about Bolt, see the official Slack documentation for Bolt for JavaScript and Bolt for Python.

Contact us

If you continue facing technical difficulties, our specialized support team is available to assist you. Contact us and we’ll be happy to help you resolve any issue: support quality is a big part of why developers rate Square Cloud 4.9/5 across 402 reviews on Google and Trustpilot.