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
- Clone the repo to your own directory:
git clone https://github.com/jalder89/Slack-Express-App-OpenAI.git
- Change into the new app directory
- Use terminal to install:
npm install
Slack App Setup
- Grab the Slack App Manifest found here
- 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
- Create a Slack App here
- Import using the updated manifest
- Install the Slack App to your workspace from the Basic Information tab
- 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.
- Create a
.env
file in your app's root directory and add the bot token: SLACK_BOT_TOKEN="yourBotToken"
- Head back to the Slack App website and navigate to the Basic Info tab, copy the Signing Secret
- Back in your
.env
file, add the Signing Secret: SLACK_SIGNING_SECRET="yourSigningSecret"
- You'll need to generate an OpenAI API key here
- Add your OpenAI API key to your
.env
file as well: OPENAI_API_KEY="yourApiKey"
MongoDB Setup
- Create and setup a MongoDB database for the AI memory, I used Atlas: MongoDB Atlas tutorial
- Get your database cluster Username and Password and add them to your
.env
file as MONGO_USER
& MONGO_PASSWORD
- Open your new cluster and click the Connect button and select Driver to view the connection string.
- Copy only the section of the URL between the @ and the first forwardslash / before the query parameters
- Add this string to your
.env
file as MONGO_CLUSTER
Hosting Locally via Ngrok
- Open a terminal to your app's root directory and start the app:
node app.js
or npm start
- Open a second terminal and start ngrok:
ngrok http 3000
- Update the Event Request URL to your ngrok forwarding URL or host address, the included one is a placeholder that is already removed.