Skip to content

hackclub/toriel

Repository files navigation

Toriel

Bot status

Toriel is currently undergoing a new revamp! You can view the stuff being worked on here, and take part in #toriel-dev, if you're on the slack

Just a lil' ol greeter bot to direct new members joining the Hack Club Slack. You wonder what she might say...

Toriel is a fork of Clippy.

Running locally

Contributions are encouraged and welcome!

In order to run Toriel locally, you'll need to join the Hack Club Slack. From there, ask @creds to be added to the Toriel app on Slack.

  1. Clone this repository git clone https://github.com/hackclub/toriel && cd toriel

  2. Install ngrok (if you haven't already)

  3. Install dependencies npm install

  4. Create .env file

    • touch .env
    • Send a message mentioning @creds in Hack Club's Slack asking for the .env file
  5. Start server npm run dev

  6. Forward your local server to ngrok ngrok http 3000

  7. Update the settings in the manifest.yml

    • Change the slash command and event endpoints by replacing https://toriel.hackclub.com with your ngrok URL
      • You can find your ngrok URL in the terminal where you ran ngrok http 3000. It would look similar to this (your ngrok URL will be different): Screenshot of ngrok running
      • Take this URL and replace it with all https://toriel.hackclub.com/slack/events URLs (the first slash command url, second slash command url, event url, and interactivity url. Include /slack/events so your new URLs would be your-ngrok-URL/slack/events.
    • Change the app and bot name from TORIEL to something that doesn't start with T (ex. msw-dev-toriel). This prevents Slack's auto-suggestions from confusing new users. Screenshot of where to change name
    • Change the slash commands from /toriel-COMMAND to something that doesn't start with t (ex. /toriel-restart -> /msw-dev-restart). Screenshot of the location of slash command
  8. Update slash commands

    • Go to index.js and find the following line Screenshot of /toriel-restart and /toriel-call
    • Change /toriel-restart and /toriel-call to your own slash commands like msw-dev-restart
  9. Go to api.slack.com to create a new slack app

    • Select "from an app manifest" Screenshot of slack app options When prompted, make sure you select the Hack Club Workspace (you might need to sign in).
    • On the next modal, replace the demo manifest with your edited manifest.yml Screenshot of manifest modal
  10. Click "Install to Workspace" under the "Basic Information" tab in the settings bar Screenshot of installing to workspace

  11. Edit the env variables in .env file.

    SLACK_SIGNING_SECRET=SIGNING_SECRET
    SLACK_BOT_TOKEN=Bot_User_OAuth_Token
    

    where SIGNING_SECRET is your app's Signing Secret, which you can find by clicking on "Basic Information" in the settings bar and scrolling down (click show to and copy it) Screenshot of where to click show and copy the signing secret and Bot_User_OAuth_Token is found under "OAuth & Permissions" (You will need click "Install to Workspace" before you can view the token) Screenshot of where the token is

  12. Create a private channel where your app can run the welcome flow. Similar to the role that #in-the-cave plays for Toriel (run toriel-restart in slack to see what this means).

    • Invite your bot to that channel (you can @mention it to add)
  13. Edit transcript.yml

    • The key:value pairs under channels: represent channel-name:channel-id and these are referred to elsewhere in the codebase with {channels.channel-name}

    Screenshot of channel list

    • You can add your own bot to these channels for testing or you can delete or comment out channels you don't need for testing

      IMPORTANT: you might need access to these channels later on, like to add a new user to channels, which means not giving your bot access now could break the app.

    • Add your own private channel to the channel list. For example, if your channel is msw-test-cave with the channel id CDF1A5EG865, you would add:

      msw-test-cave: CDF1A5EG865
      
    • You can find the channel ID by opening the channel and clicking on the channel name in the top left. Scroll down the modal and you should see it in the bottom left corner Screenshot of channel ID

  14. Do a global find and replace in the codebase to update channels.cave to channels.name-of-your-private-channel

    • As {channels.cave} refers to #in-the-cave, we need to replace it with the private channel (ex. {channels.msw-test-cave}) that you created for your bot
  15. Run npm run dev again and also reinstall your app to the workspace (under Basic Information) Screenshot of reinstall your app page

If you run into an error where the message reads Toriel is not invited to these channels or channel_not_found, just invite your bot to that channel (you can check the channel with its ID by referring back to transcript.yml. If the channel is private, you can create a new private channel as its substitute, but remember to update the references in the code. Ex. #toriels-diary is a private channel, so you can create #msw-toriels-diary, add it to transcript.yml, and change all {channels.toriels-diary} to {channels.msw-toriels-diary}.

Note: you have to re-update the ngrok URL on the Slack app manifest and verify the URL each time to restart the server, since the ngrok URL changes

Formatting is important, please run npm run fmt on contribution.

About

πŸ‘‹ A friendly bot that assists new members with joining Hack Club

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published