Custom Installation

Emily AI Image

Installation

To host this app yourself you will need access to OpenAI API, a Slack App, a way to host the app, and a MongoDB database for hosting the AI's conversational memory. You can try out a non-production version of Emily AI by installing the development app here.

To set things up, follow these steps (Mac):

Repository Setup

  1. Clone the repo to your own directory: git clone https://github.com/jalder89/Slack-Express-App-OpenAI.git
  2. Change into the new app directory
  3. Use terminal to install: npm install

Slack App Setup

  1. Grab the Slack App Manifest found here
  2. Update the Request URL in the manifest to point to the URL where your app will be listening for Slack events or we'll cover ngrok forwarding in a bit
  3. Create a Slack App here
  4. Import using the updated manifest
  5. Install the Slack App to your workspace from the Basic Information tab
  6. Head to the OAuth & Permissions and copy the Bot Token

Environment Variables

Setting up environment variables will depend on how you are hosting the app. The following covers hosting locally via Ngrok.

  1. Create a .env file in your app's root directory and add the bot token: SLACK_BOT_TOKEN="yourBotToken"
  2. Head back to the Slack App website and navigate to the Basic Info tab, copy the Signing Secret
  3. Back in your .env file, add the Signing Secret: SLACK_SIGNING_SECRET="yourSigningSecret"
  4. You'll need to generate an OpenAI API key here
  5. Add your OpenAI API key to your .env file as well: OPENAI_API_KEY="yourApiKey"

MongoDB Setup

  1. Create and setup a MongoDB database for the AI memory, I used Atlas: MongoDB Atlas tutorial
  2. Get your database cluster Username and Password and add them to your .env file as MONGO_USER & MONGO_PASSWORD
  3. Open your new cluster and click the Connect button and select Driver to view the connection string.
  4. Copy only the section of the URL between the @ and the first forwardslash / before the query parameters
  5. Add this string to your .env file as MONGO_CLUSTER

Hosting Locally via Ngrok

  1. Open a terminal to your app's root directory and start the app: node app.js or npm start
  2. Open a second terminal and start ngrok: ngrok http 3000
  3. Update the Event Request URL to your ngrok forwarding URL or host address, the included one is a placeholder that is already removed.