A combination repo of a web-app and a zulip bot.
Collects advice from RC alums! Uses mongodb atlas for a DB and hosted on heroku.
Steps to run locally:
- Create a file called
.envin the root of the project similar to the.env.examplefile - You will need an OAUTH client ID and client secret, you can generate this in recurse.com settings > apps and copy it into your
.envfile asOAUTH_CLIENT_IDandOAUTH_CLIENT_SECRET - You will need a MongoDB atlas DB. You can create one and copy it into your
.envfile asMONGODB_URI SESSION_SECRETcan be any random string- Run
npm installto install all dependencies - Run
npm run devto run it locally - Go to
http://localhost:3001, you should see the front-end - Ping me on zulip if this doesn't work
Recursers can subscribe to the "Advice of the Day!" bot to get one piece of advice from an RC alum everyday
https://recurse.zulipchat.com/#narrow/pm-with/506831-advice-bot
Steps to run locally:
- You will need to do all the steps to run the web app locally above (since the bot needs the APIs)
- Run an ngrok tunnel that points to
http://localhost:3001 - Create a new file in the project root called zuliprc
- Create a new bot in Zulip > gear icon > Personal settings > Bots as an outgoing webhook with the Endpoint URL set to
<your-ngrok-url>/api/bot/handleMessage - Copy paste the bot config (zuliprc) into your zuliprc file
- Now if you DM your bot, you should get a response
(Defined in the /api/scheduled.js file)
This project uses cron-job.org to schedule tasks:
-
/api/scheduled/sendAdviceis called everyday. This API sends one random piece of advice from the database to all subscribers. -
/api/scheduled/introduceBotis called every week on Wednesdays. This API checks whether a new batch has started in the last week, and sends an introductory message on Zulip if so.NOTE: You will need a recurse.com personal access token to run this API locally, since it needs to check whether a new batch has started. You can get a personal access token from recurse.com settings > apps and paste it to your
.envfile asPERSONAL_ACCESS_TOKEN
(Defined in the /api/bot.js file)
/api/bot/handleMessageis called from the zulip bot (which is defined as an outgoing webhook)
(Defined in the /api/advice.js file, these APIs are called from the frontend)
/api/advice/submit/api/advice/listlists all the advice submitted by a logged-in user

