# Cloud Commands

Cloud commands are hosted at URL endpoints. Slapdash makes HTTPS requests to the endpoint and interprets the JSON-encoded [Command Response](https://platform.slapdash.com/reference/command-response).\
\
Commands that run in the cloud can't make any changes to your computer (it's just JSON over HTTPS after all), so they are a safe way to share Command Bar functionality with others.

## Create Cloud Command

To create a cloud command, run **Create Command** in the Command Bar, choose **Cloud** as a type, paste the **Endpoint URL** of your command, give it a name and press **Create Command**.

![](https://2278499523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbsXkso5TLXDAfcG2Q2%2Fuploads%2Fgit-blob-86508bc61e7432acdf517a103ff8878d18d4e85b%2Fcleanshot-2021-08-20-at-16.22.14.png?alt=media\&token=b46d1c0e-c778-40e9-942c-0d286b2955b4)

## Developing & Deploying with Replit

One of our favourite ways to host and develop cloud commands is with [Replit](https://replit.com).\
\
We like it because we can use any programming language to write the command, and we can do the development directly in the browser. It's a super quick way to get an HTTPS endpoint up and running with just a few clicks.\
\
**Fork Example**

The fastest way to start is to fork another Repl. Here are a few examples you can choose from:

* [Basic Python Example](https://replit.com/@slapdash/slapdash-command-python)
* [Send Slack Message](https://replit.com/@slapdash/send-slack-message)

**Run Command**

After forking the Repl, hit the **Run** button to make sure the associated HTTPS endpoint is accessible.\
\
Find the endpoint URL in the top-right panel. This is the URL you will use to create the command inside Slapdash.

![](https://2278499523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbsXkso5TLXDAfcG2Q2%2Fuploads%2Fgit-blob-d24658d0f233b7201a52e239cc2ce9106eaf2959%2Fscreen-shot-2021-06-18-at-3.10.48-pm.png?alt=media\&token=5b7c3a60-0ea4-489d-9bd0-34a1f556c7ac)

\
**Deploying & Sharing Command**\
By default, Repls aren't always running. If you plan to use the command often or to share it with others, you'll need to make sure the Repl is set to be **Always On.**

## Deploying with Vercel

You can also use Vercel to deploy a command as a [Serverless Function](https://vercel.com/docs/serverless-functions/introduction).

Start by creating a **New Project** inside Vercel and choose the **NextJS template**.

Create a new file in the project under `pages/api/ahoy-world.js`.

Then, add the following sample code and push to your repository to deploy it.

```javascript
module.exports = async (req, res) => {
  const response = {
    view: {
      type: "list",
      options: [
        {
          title: "Open Slapdash",
          action: {
            type: "open-url",
            url: "https://slapdash.com"
          }
        },
        {
          title: "Copy Heart Emoji",
          action: {
            type: "copy",
            value: "❤️"
          }
        }
      ]
    }
  };
  res.setHeader("Access-Control-Allow-Headers", "*"); // for config headers
  res.setHeader("Access-Control-Allow-Origin", "*");
  res.json(response);
}
```

At this stage, you should have a functioning URL like `https://nextjs-***.vercel.app/api/ahoy-world` that you can use to create a command in Slapdash.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform.slapdash.com/command-bar-101/cloud-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
