Configure Top.gg Webhook on Square Cloud
A detailed guide to setting up the Top.gg webhook on Square Cloud.
Introduction
- This guide assumes you have an approved bot on top.gg and are using either Node.js or Python for your project.
- Next, you will need to create an account on Square Cloud, which can be done through the sign up page. You can use your email to create an account.
- Finally, you need to have an active paid plan on your account. You can view our plans and purchase one according to your needs here.
Setting Up the Environment
- Before you begin, make sure you have Node.js and npm installed on your system. If you don’t have them yet, you can download them from the official Node.js website.
- Start a new Node.js project with the following command:
This command creates a package.json file in the current directory.
- Install the necessary libraries:
Setting Up the Project
1. Get your webhook authentication:
- Go to your Top.gg profile here.
- Click “edit” on the bot you want to receive notifications for votes.
- Under “GENERAL”, choose the “webhook” option.
- Set the webhook authentication in “Authorization”. In this example, we used “myappsquare”.
2. Implement the webhook listener:
The following sections provide code examples for both Javascript and Python:
We will use the example provided by the top.gg documentation here, with some modifications.
Creating the squarecloud config file
Learn about: how to make the configuration file for Square Cloud.
The squarecloud.app file is a configuration file that will be used to configure your application; it will be used to define the name, description, version, main file, among other things.
Uploading Your Application to Square Cloud
After following all the steps, put your application files into a .zip
file, including the configuration file.
If your application is a Node.js project, take a look at our article on Node.js.
If your application is a Python project, take a look at our article on Python.
Access the Square Cloud Dashboard and upload your project files.
Troubleshooting
Starting Tests
If you have done everything correctly, try accessing your site using the subdomain defined in the configuration file. If you defined it as “mysite”, to access it will be https://mysite.squareweb.app/
. After you access and only “Cannot GET /” or “Method Not Allowed” appears, everything is okay.
Now, you need to go back to the previous page where the authorization was defined. In the Webhook URL field, you should put the URL of your site with the route that will receive the votes.
-
For the JavaScript code we created with
app.post("/topgg", webhook.listener((vote) => {...})
, the route that will receive the votes is “/topgg”. So, if your website is “https://mysite.squareweb.app”, you should put “https://mysite.squareweb.app/topgg” as the Webhook URL. -
For the Python code we created with
@app.route("/topgg", methods=["POST"])
, the route that will receive the votes is also “/topgg”. So, the Webhook URL would be the same “https://mysite.squareweb.app/topgg”.
Finally, click on the “Send Test” button. After that, check the terminal. If everything went well, the message you defined in console.log
or print
should appear in the terminal.
And with that, if everything has been configured correctly, your webhook will be ready to send notifications when your bot receives a vote on top.gg.
If you continue to experience any issues, please don’t hesitate to contact our support team.
Was this page helpful?