Add a Bot to Channels

I found this line in docs https://docs.mattermost.com/developer/bot-accounts.html.

  1. Add the bot account to teams and channels you want it to interact in.

But when I go to add my bot into a channel, there are only users.

When I create a new bot, the bot said Please add me to teams and channels you want me to interact in., but there isn’t any button below this message.

image

According to the docs

Bot accounts can be enabled to post to any channel in the system by System Administrators, including a private team, private channel or a Direct Message channel.

Once created, bot accounts behave just like regular user accounts and can be added to teams and channels similar to users.

My bot is a System Administrator so it can’t direct message on any channels, but my bot build in mmpy_bot only work on Direct Message, and won’t reply the messages on any other channels.

@sheiun What Mattermost server version are you on?

@amy.blais
Mattermost Team Edition
Mattermost Version: 5.15.0

@sheiun Has the bot been added to the team in which the channel where you’re trying to add the bot to is located?

@amy.blais No, I don’t think so. And the bot is only in direct message area.

@sheiun Can you help first add the bot to the team where the channel in which you’re trying to add the bot in is located?

@amy.blais It seems that I don’t find the option to add the bot to current team.

Should it be in admin panel or integration panel?

@amy.blais The problem just seems that I asked there isn’t any button for me to use when I create the bot.

Same here, how add bot to channel?

Are you able to add a bot to a channel from the “Members > Manage Members” channel menu?

No, I can’t. The panel only shows the real user.
Do I need to modify settings of team?

Oh wow, I resolve it by “Main Menu > Add members to team”

I thought it is a translation problem, that button “新增成員” means “Add member” that didn’t mention the team.

And in “Main Menu > Manage Members” only shows the members that already joined to the team.

You can consider my solution.

“Main Menu > Add Members to team” then you can see all bot accounts.

After you add bot to your team, go to channel and “Members > Manage Member”

image

3 Likes

@sheiun

Hi Bro, I think I found the solution.
I don’t know if you still need the solution, but I’ll write it here as a note.

Here are the steps:

  1. Make a bot (follow the steps here), Please remember the {bot_username}
  2. Go to CLI and convert it into a normal user
mattermost user convert {bot_username} --user --email {avaliable.mailaddr@email.com} --password {bot_password}
  1. Go to your chatbot server and login with the {avaliable.mailaddr@email.com} and {bot_password}
    2.5. (You may need the mail verification. Do it.)
  2. Join the Team
  3. Run your bot with your {api_token} {avaliable.mailaddr@email.com} and {bot_username}

After these steps, your bot will be treated as a normal user. So you could invite it to any channels.

BTW, I am using the python bot module mmpy_bot

1 Like

Just in case someone still has problems with that. You just need to read the docs:

To authorize your bot via RESTful API use curl -i -H 'authorization: Bearer <Access Token>'http://localhost:8065/api/v4/users/me . Access Token is not the Token ID and won’t be visible again once created.

After doing that you can click on the Team and “invite people”. The Bot should show up there. Add it to the team and it will then be available in the list of users that you can invite to private channels etc.

1 Like