Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to build a slack bot and facing error "Error: not_allowed_token_type"

Was just trying to build a simple slack bot by following a YouTube link and started getting the error Error: not_allowed_token_type

const bot = new SlackBot({
token: 'xoxb-TOKEN_GENERATED FROM SLACK SITE',
name: 'escalatorbot'  // what name should I give here
})

Can somebody tell why I am facing this error

like image 382
Osten Diniz Avatar asked Mar 05 '20 06:03

Osten Diniz


People also ask

How do I create a bot token in slack?

Create a Slack app if you don't already have one, or select an existing app you've created. Click the OAuth & Permissions tab in the left sidebar. Below Bot Token Scopes, select one or more scopes.

What are Slack Tokens used for?

Access tokens Access tokens are the keys to the Slack platform. Tokens tie together all the scopes and permissions your app has obtained, allowing it to read, write, and interact. There are multiple types of access token available.

What is a bot in slack?

A bot is a nifty way to run code and automate messages and tasks. In Slack, a bot is controlled programmatically via a bot user token that can access one or more of Slack’s APIs.

How do I add an OAuth scope to my slack app?

Create a Slack app if you don't already have one, or select an existing app you've created. Click the OAuth & Permissions tab in the left sidebar. Below Bot Token Scopes, select one or more scopes. Then click Add an OAuth Scope.


2 Answers

From your code snippet, I think you're using Slackbots.js and encountering a known problem resulting from recent changes in the slack api. The issue is logged here: https://github.com/mishk0/slack-bot-api/issues/145

like image 82
baob Avatar answered Oct 19 '22 06:10

baob


The issue is releated with the new granular permissions app in slack, use the legacy bot on this url: https://api.slack.com/apps?new_classic_app=1 and then in Bots you can add legacy bot user and generate correct token

like image 43
Dorian Morones M. Avatar answered Oct 19 '22 07:10

Dorian Morones M.