# Build Your First App

Source: https://marketplace.gohighlevel.com/docs/2023-02-21/app-studio/BuildYourFirstApp

This guide walks through building an app with App Studio, from the first description to a working page. If you haven't turned App Studio on yet, start with [App Studio](./Overview.md#turn-on-app-studio).

---

## 1. Describe your app

Open App Studio in one of these ways:

- In the Developer Portal, go to **My apps**, click **Create app**, then choose **Build with App Studio**.
- In **Labs**, click **Open App Studio** on the Marketplace App Studio card.

Describe what your app should do and who uses it, then press **Enter** (or click the arrow). Use **Shift+Enter** for a new line.

![The App Studio start page with the description box and idea chips](./img/create-page.png)

- **Not sure where to start?** Click one of the ideas under **Try an idea** to fill in a ready-made description, then edit it.
- **Have a sketch or a screenshot?** Click the paperclip to attach images (PNG, JPEG, GIF or WebP, up to 5 images of 5 MB each).

A good first description says **where** the app shows up, **who** uses it, **what data** it works with, and **what happens** when someone clicks. For example:

```text
A page in the sub-account's left menu for front-desk staff. It lists today's appointments
from the sub-account's calendars with the contact's name and phone. Each row has a
"Send reminder" button that texts the contact: "Hi {first name}, see you today at {time}."
Show a toast when the text is sent.
```

See [Prompting best practices](./PromptingBestPractices.md) for more examples.

---

## 2. Watch it build

App Studio creates the app and opens the builder. It names your app from your description; you can rename it later.

While it works, the chat shows its plan as a checklist and the steps it takes, such as looking up the HighLevel APIs it needs and editing files. A first build usually takes a few minutes; small changes often take less than a minute.

While a change builds, the preview keeps showing your last version (*"Showing version 3 until this finishes"*), so you can keep looking around.

![App Studio building a change: the step in progress in the chat, Building… at the top, and the last version still in the preview](./img/build-in-progress.png)

- Click **Stop** (the square button) to stop a build. Work done so far is kept.
- You can type your next message while it builds, and send it when the build finishes.
- Your team builds one project at a time. If another project on your team is building, wait for it to finish.

---

## 3. Review the result

When the build finishes, App Studio tells you what it built, and saves it as a new version.

![The builder after a build: the summary in the chat, and the Front desk page with sample appointments in the preview](./img/builder-overview.png)

The chat shows:

- **A summary** of what changed and how to try it.
- **Settings updated from your code**: the permissions (scopes) and pages App Studio set on your app. App Studio works out the scopes from the HighLevel APIs your code calls, so you never pick them by hand.
- **Next**: the suggested next step.
- **Suggestions** above the message box for follow-up changes. Clicking one sends it right away.

Under each reply you can restore that version, copy the reply, rate it, or **Report a problem**.

---

## 4. Find your way around the builder

| Area | What it's for |
|---|---|
| **Top bar** | Your app's name and status (**Not published**, **Saved**), **Try it in HighLevel** and **Publish**. Click the app name for **All settings** and **Version history**. |
| **Chat** (left) | Describe changes, answer App Studio's questions, and follow each build. Drag the divider to resize it. |
| **Preview** (eye icon) | Your app running live. Until you [try it in HighLevel](./TestInHighLevel.md), pages that show HighLevel data show a placeholder. |
| **Code** (`<>` icon) | Every file App Studio wrote. |
| **Backend** (database icon) | Your app's database and environment variables. |

### Preview

The preview runs your app as a sub-account user would see it. The bar above it shows which sub-account it uses. Click **Reload** (top right) to restart it.

Pages that read HighLevel data, such as contacts or appointments, need a real sub-account. Until you pick one, they say *"This page shows HighLevel data"*. Click **Try it in HighLevel** to connect one, see [Try your app in HighLevel](./TestInHighLevel.md).

:::tip Preview with sample data
To see your page filled in before you connect a sub-account, ask for sample data. For example:

```text
When no sub-account is connected, show 6 sample appointments on the Front desk page so the
page can be previewed. Show a small "Sample data" badge next to the title while they're
shown. Keep using real appointments once a sub-account is connected.
```

The screenshots on this page were taken this way.
:::

### Code

The Code tab shows the app's files, read-only. Changed files are marked with a dot. Click **Download codebase** to download the whole project.

![The Code tab with the project files and the code of the Front desk page](./img/code-tab.png)

Two files describe your app to HighLevel, and App Studio keeps them in sync with your app's settings:

- `app.contract.ts`: the app's pages and where they appear (for example, the sub-account's left menu).
- `app.scopes.json`: the scopes your code needs, worked out from the HighLevel APIs it calls. Don't edit it.

### Backend

**Database** shows the tables your app created and their rows. Switch between **Test data** (what the preview uses with your test sub-account; your clients never see it) and **Live data** (what your clients' installs use).

![The Backend tab showing the Database section with Test data and Live data](./img/backend-database.png)

You don't create tables yourself. Describe the data in chat, for example *"Save each reminder that was sent, with the contact and the time"*, and App Studio creates the table.

**Environment variables** holds API keys and other values your app needs at runtime, such as a key for an outside service.

![The Environment variables section with Paste .env and Add variable](./img/backend-env.png)

- Click **Add variable**, or **Paste .env** to add several at once.
- Secret values are write-only: your app can read them, but nobody can see them in App Studio again.
- App Studio's AI sees variable names, never values.
- Never put a secret in a variable whose name starts with `VITE_`. Those values are compiled into the page that runs in the browser, where anyone can read them.

### Version history

Every build is saved as a version. Click the app name, then **Version history**, to see them. Click **Restore** to go back to a version. Restoring keeps your current version too, so you can return to it.

![Saved versions listed in the version history panel](./img/version-history.png)

---

## 5. Keep building

Ask for one change at a time, check it in the preview, then ask for the next. When it looks right:

1. [Try it in HighLevel](./TestInHighLevel.md) with real data.
2. [Publish it and share the install link](./PublishAndShare.md).
