-
Notifications
You must be signed in to change notification settings - Fork 0
AchoBot setup Full guide
AchoBot requires the following dependencies to run:
- Node.js
- npm
- Notion API Key
- Notion Database
- Twitch Account
- Twitch Application
Follow these steps to get everything you need from Notion and Twitch.
You'll need a Notion API key and Database ID.
- Go to https://developers.notion.com/my-integrations
- Click over "+ New integration"
- Fill the form with a Name. E.g: "AchoBot"
- Select the option "Internal integration"
- Under "Capabilities" select "Read content" (that's the only one AchoBot needs)
- Under "User capabilities" select "No user information" (AchoBot doesn't need to access to any user information).
- Submit the form
- Save the Internal Integration Token somewhere secure. You'll need to add it as an Environment variable later.
- Setup your Notion Database. Generate it using the following Notion template: [Template] AchoBot
Press "Duplicate" to copy the template in your Notion. The template comes with a few sample commands; feel free to delete them and add your own.
Make sure the database is generated in the same workspace as your Notion Integration.
-
Share the integration with your database:
- Open your newly created AchoBot Database
- Click "Share"
- Find your integration by typing its name in the search box
- Press "Invite"
-
Open the database in Notion and get the Database ID:
- Press "Share"
- Select "Copy Link"
- The ID is the route parameter in the URL before the
?
:
https://www.notion.so/a8aec43384f447ed84390e8e42c2e089?v=... |--------- Database ID --------|
- Save the ID somewhere. You'll need to add it as an Environment variable later.
More information about Notion Integrations here: https://developers.notion.com/docs/getting-started
You can register the App using your personal Twitch account or create a new one. The latter is recommended so people in the chat know when they are talking to you or your bot.
💡 Tip: You can check an option in your personal account to enable creating additional accounts with the same verified email. This option can be found in
Settings > Security and Privacy > Contact
below your verified email.
- Go to the developer console
- Select "Register your Application"
- Fill out the form:
- After submitting you should see the following table
-
Press over the "Manage" button
-
Generate a "Client Secret" by pressing over the "New Secret" button:
Take note of both the Client ID and the Client Secret. You will need them to connect your chatbot with the Twitch API.
- Clone the repo
git clone https://github.com/pawap90/acho-bot
- Install dependencies: Run the following command from the project's root folder:
npm install
To run AchoBot we first need to set up all the environment variables. If you are running it locally, simply create a file in the root folder and name it .env
. The file should contain the following information:
TWITCH_BOT_CLIENTID=<your-twitch-clientid> # The Client ID we got on section 1.3
TWITCH_BOT_CLIENTSECRET=<your-twitch-secret> # The Client Secret we got on section 1.3
TWITCH_BOT_USERNAME=<your-bots-username> # The username of the Twitch account you created for the bot (section 1.3)
TWITCH_CHANNELS=<your-twitch-channel> # Your Twitch channel or the channel where you want the bot to join the chat.
TMI_DEBUG=true
TMI_LOGLEVEL=info
PORT=5000 # The port where the app should run
TWITCH_BOT_REDIRECTURI=http://localhost:5000/api/twitch/auth/token # Make sure the port matches with "PORT"
SESSION_SECRET=<a-random-value>
NOTION_APIKEY=<your-notion-api-key> # The Notion API Key we got on section 1.1
NOTION_DATABASEID=<your-notion-database-id> # The Notion DB ID we got on section 1.2
NOTION_VERSION=2021-08-16 # The Notion API version we are using
After everything is set up, you can run the bot using the following commands:
npm run build
npm start
Or you can run it in development mode:
npm run dev
In the logs, you will see AchoBot trying to connect but failing. This is because we haven't logged in yet!
Since you are going to log in with your bot's account, I recommend doing this in a different browser (or the same browser in private mode) than the one you use to log in with your main account.
- While the project is running, navigate to
http://localhost:5000/api/twitch/auth
- Login with your bot's Twitch account
- You will be redirected to
http://localhost:5000
and you should see a green message indicating you logged in successfully. - Wait a minute or so and AchoBot will automatically connect to your stream's chat
You don't need to be streaming to test AchoBot! Go to https://dashboard.twitch.tv/u/<your-channel>/stream-manager
and start typing commands in the chat (at the bottom left corner). AchoBot should be able to respond by now!