Welcome to our first article of practical use cases and example scripts that you can automate in two clicks with the Jotcode application.

In this first article, we will teach you how to easily create a script that allows you to create custom Slack commands.

Are you ready? Let’s go

1. Create a Slack application

If you want to create a custom Slack command, the first step is to create a Slack application. It’s easy to do, just follow this link: https://api.slack.com/apps.

Create a new application using the “Create a new application” button. Then, install it in your workspace by clicking on “Install App”.

screensot

2. Create a sample backend in the Jotcode application

In order to create a new Slack command, your application will need to communicate with an endpoint backend, which will implement the interactions of your command. This is where we can help. Go to the Jotcode app and create a new script containing the following code:

function main(input, context, callback){
  callback(null, {
    body: 'It works!
  })
}

This code is a minimalist example of a backend that always responds “It works”.

3. Bring your backend online

The next step is to put your example backend online. To do this, go to the settings of your script, and choose an execution mode of “Webhook”.

You will get a unique link, allowing you to execute your script. This link should look like the following:

https://backend.jotcode.io/scripts/public_run/10d81457-82f1-4b5f-8300-38664c70cea8

The last step will be to inform the Slack application of a link to your command backend. To do this, go to the “Slash Commands” section. Create a new order and fill in the link to the newly created backend script. That’s it 🎉 you’ve created your first Slack command.

screensot

5. Want to go further?

Your imagination is your limit. You can now create as many new commands as you want. You will just need to create a new Jotcode script per backend endpoint corresponding to a new command.

Want to add new features, simply modify the sample script to achieve the desired functionality: calculation, extraction, data modification, do what you want.