|
| 1 | +# AI Agent App Template (Bolt for JavaScript) |
| 2 | + |
| 3 | +This Bolt for JavaScript template demonstrates how to build [AI Apps](https://docs.slack.dev/ai/) in Slack. |
| 4 | + |
| 5 | +Models from [OpenAI](https://openai.com) are used and can be customized for prompts of all kinds. |
| 6 | + |
| 7 | +## Setup |
| 8 | + |
| 9 | +Before getting started, make sure you have a development workspace where you have permissions to install apps. If you don’t have one setup, go ahead and [create one](https://slack.com/create). |
| 10 | + |
| 11 | +### Developer Program |
| 12 | + |
| 13 | +Join the [Slack Developer Program](https://api.slack.com/developer-program) for exclusive access to sandbox environments for building and testing your apps, tooling, and resources created to help you build and grow. |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +### Create a Slack App |
| 18 | + |
| 19 | +1. Open [https://api.slack.com/apps/new](https://api.slack.com/apps/new) and |
| 20 | + choose "From an app manifest" |
| 21 | +2. Choose the workspace you want to install the application to |
| 22 | +3. Copy the contents of [manifest.json](./manifest.json) into the text box that |
| 23 | + says `*Paste your manifest code here*` (within the JSON tab) and click _Next_ |
| 24 | +4. Review the configuration and click _Create_ |
| 25 | +5. You'll then be redirected to App Settings. Visit the **Install App** page and install your app. |
| 26 | + |
| 27 | +### Environment Variables |
| 28 | + |
| 29 | +Before you can run the app, you'll need to store some environment variables. |
| 30 | + |
| 31 | + |
| 32 | +1. Rename `.env.sample` to `.env`. |
| 33 | +2. Open your apps setting page from [this list](https://api.slack.com/apps), click _OAuth & Permissions_ in the left hand menu, then copy the _Bot User OAuth Token_ into your `.env` file under `SLACK_BOT_TOKEN`. |
| 34 | +```zsh |
| 35 | +SLACK_BOT_TOKEN=YOUR_SLACK_BOT_TOKEN |
| 36 | +``` |
| 37 | +3. Click _Basic Information_ from the left hand menu and follow the steps in the _App-Level Tokens_ section to create an app-level token with the `connections:write` scope. Copy that token into your `.env` as `SLACK_APP_TOKEN`. |
| 38 | +```zsh |
| 39 | +SLACK_APP_TOKEN=YOUR_SLACK_APP_TOKEN |
| 40 | +``` |
| 41 | +4. Save your OpenAI key into `.env` under `OPENAI_API_KEY`. |
| 42 | +```zsh |
| 43 | +OPENAI_API_KEY=YOUR_OPEN_API_KEY |
| 44 | +``` |
| 45 | + |
| 46 | + |
| 47 | +### Local Project |
| 48 | + |
| 49 | +```zsh |
| 50 | +# Clone this project onto your machine |
| 51 | +git clone https://github.com/slack-samples/bolt-js-assistant-template.git |
| 52 | + |
| 53 | +# Change into this project directory |
| 54 | +cd bolt-js-assistant-template |
| 55 | + |
| 56 | +# Install dependencies |
| 57 | +npm install |
| 58 | + |
| 59 | +# Run Bolt server |
| 60 | +npm start |
| 61 | +``` |
| 62 | + |
| 63 | +### Linting |
| 64 | + |
| 65 | +```zsh |
| 66 | +# Run lint for code formatting and linting |
| 67 | +npm run lint |
| 68 | +``` |
| 69 | + |
| 70 | +## Project Structure |
| 71 | + |
| 72 | +### `manifest.json` |
| 73 | + |
| 74 | +`manifest.json` is a configuration for Slack apps. With a manifest, you can create an app with a pre-defined configuration, or adjust the configuration of an existing app. |
| 75 | + |
| 76 | +### `app.js` |
| 77 | + |
| 78 | +`app.js` is the entry point for the application and is the file you'll run to start the server. This project aims to keep this file as thin as possible, primarily using it as a way to route inbound requests. |
0 commit comments