Filipe Ferminiano
Filipe Ferminiano

Reputation: 8791

Unable to add bot through slack api

I'm trying to write a Slack bot following this tutorial.

But I'm not being able to add a bot user to my channel after login. These are the scopes I'm requiring. After I Allow my app to a access my channel, no bot is added with the name I specified in the app dashboard.

Route::get('/login/slack', function(){
    return Socialite::with('slack')
        ->scopes([
            'bot',
            'channels:read',
            'channels:write',
            'chat:write:bot'
            ])
        ->redirect();
    });

And this is my redirect function:

Route::post('/slack', function(\Illuminate\Http\Request $request)
{

    $payload = $request->all();

    if ( isset($payload['type']) && isset($payload['challenge']) )
    {
        if ($payload['type'] == 'url_verification')
        {
            return $payload['challenge'];
        }
    }

    $slackbot = new SlackBot();
    $slackbot = SlackBot::initialize('xoxb-XXX');


    // give the bot something to listen for.
    $slackbot->hears('hello', function (SlackBot $bot, $message) {
      $bot->reply('Hello yourself.');
    });


    // Bot logic will be placed here
});

So, how can I add the bot to my channel through the api?

Upvotes: 0

Views: 608

Answers (1)

Erik Kalkoken
Erik Kalkoken

Reputation: 32697

It is not possible to add a bot user through the API.

Bot users can be added only with one of two apporaches:

  1. Add a custom bot user Install a Slack app that has a bot user
  2. Install a Slack App that has a bot user

See the documentation for details.

Upvotes: 3

Related Questions