Introduction
To develop and host an X (Twitter) bot on Square Cloud, you should follow a specific sequence of configurations and prerequisites. This technical guide covers the entire process, from initial setup to production deployment.Essential Prerequisites
- Active X (Twitter) account: Required for authentication and bot operation. If you don’t have an account, sign up at the official X website.
- X Developer account: Required to access the APIs. Request access through the X Developer Portal.
- Active Square Cloud account: Hosting platform for your application. Sign up via the signup page using your email.
- Active paid plan: Ensures dedicated resources and optimized performance. Check our available plans and choose the one that suits your needs.
1
Accessing the Developer Portal
- Go to the X Developer Portal.
- Log in with your X (Twitter) account.
- If this is your first time, complete the developer access request process.
2
Project Creation
- In the dashboard, click “Create Project”.
- Choose a name for your project (e.g. “Square Cloud Bot”).
- Select the most appropriate use case (e.g. “Making a bot”).
- Provide a detailed description of your bot.
- Confirm project creation.
3
Application Setup
- Within the created project, click “Create App”.
- Define a unique name for your application.
- Confirm application creation.
- Note down the generated App ID for future reference.
4
API Keys Generation
- Navigate to the “Keys and tokens” section of your application.
- In the “Consumer Keys” section, click “Regenerate” to generate:
- API Key (Consumer Key)
- API Secret Key (Consumer Secret)
- Important: Copy and save these keys immediately, as you won’t be able to view them again.
5
Permissions Configuration
- Go to the “App permissions” section.
- Click “Edit” to modify permissions.
- Select “Read and write” to allow your bot to post tweets.
- If necessary, select “Read and write and Direct message” for DM functionality.
- Save the changes.
6
Access Tokens Generation
- Return to the “Keys and tokens” section.
- In the “Access Token and Secret” section, click “Generate”.
- Confirm token generation.
- Copy and save:
- Access Token
- Access Token Secret
- Warning: These tokens cannot be viewed again after closing the page.
7
Credentials Verification
- Confirm that you have all 4 required credentials:
- API Key (Consumer Key)
- API Secret Key (Consumer Secret)
- Access Token
- Access Token Secret
- Store these credentials in a secure location
- Important: Never share or expose these credentials publicly
Development Environment Setup
Node.js Installation and Setup
- Node.js check: Verify that Node.js is installed on your system. If not, download it from the official Node.js website.
- Project initialization: Create a new Node.js project by running:
Terminal
- Install dependencies: Install the libraries required for the bot:
Terminal
X (Twitter) Bot Implementation
- Environment variables setup: Create a
.env
file to store your credentials securely:
.env
- Create the main file: Develop the
index.js
file with the bot’s base structure:
index.js
Square Cloud Configuration File
Technical documentation: Square Cloud configuration file
The
squarecloud.app
file is the core configuration of the application, defining key parameters such as the main file, resource allocation, runtime versions and important project metadata.Configuration Example
Create thesquarecloud.app
file in your project root:
squarecloud.app
Advanced START Field Configuration
Technical warning: Use the START field only if you have advanced knowledge about custom startup scripts and their implications.
Environment Variables Configuration on Square Cloud
Security: Never include your API credentials directly in code. Always use environment variables on Square Cloud.
API_KEY
: Your X API keyAPI_SECRET_KEY
: Your X API secret keyACCESS_TOKEN
: Your access tokenACCESS_TOKEN_SECRET
: Your access token secret
Deploy and Hosting on Square Cloud
After preparing your project files, proceed with the upload using one of the available methods:Go to the Square Cloud Dashboard and upload your project files through the web interface.
