attzonko / mmpy_bot

A python-based chatbot for Mattermost (http://www.mattermost.org).
MIT License
261 stars 103 forks source link

mattermost 5.12 bot accounts channel messages #109

Closed Celforyon closed 5 years ago

Celforyon commented 5 years ago

Mattermost 5.12 has recently been released, including Bot Accounts.

short version:

longer version: I managed to configure mmpy_bot to use a bot account, using the token instead of the password, and it connects and answers direct messages.

However, in another channel where the bot can talk, it does not answer to messages including a mention (e.g. @bot). I suspect that it could be related to the impossibility to really "add to channel" the bot in the Mattermost interface.

elixx commented 5 years ago

Is there a way to convert a bot user back into a regular user?

I am impacted by this.

attzonko commented 5 years ago

Ok I have read through the documentation on bot accounts. One thing sticks out at me:

Bot accounts are just like user accounts, except they:

- Cannot be logged into.

The whole premise off mmpy_bot is that it logs-in as a "normal" user and can be added to channels and interacted with just like any other user. I have not found any use case described where these new "bot accounts" can listen to and respond to messages. I could not even get direct messages working, how did you do it @Celforyon?

@elixx As far as I read there was no way mentioned to revert that conversion. You can just try to delete the bot account and and create the original account from the command line.

I have sent in a question about this to the Mattermost developers, will keep you posted.

Celforyon commented 5 years ago

I nearly did nothing. I used as usually my mmbot Docker image (celforyon/mmbot) which is directly using mmpy_bot without any changes. My docker-compose.yml file is:

version: '2'     
services:
  mmbot:
    container_name: mmbot
    image: celforyon/mmbot
    network_mode: bridge
    restart: always
    environment:
    - MATTERMOST_DOMAIN=#censored url#
    - MATTERMOST_BOT_LOGIN=testbot
    - MATTERMOST_BOT_TOKEN=#censored token#
    - MATTERMOST_BOT_TEAM=Home
    - MATTERMOST_BOT_PLUGINS_ONLY_DOC=True
    volumes:
    - #censored path#:/plugins
    - #censored path#:/data

The token has been given by Mattermost right after creating the bot account.

Then, as I explained in my first message, it works with direct messages. If you want, I can setup a server for you to test my configuration. Tell me if you are interested.

attzonko commented 5 years ago

Ok I dug a bit deeper, and actually using bot accounts works just fine.

For me the missing piece of the puzzle was adding the bot account to the Team first, before trying to add the bot account to specific channels within the team. With that step taken care of, the bot account works without any problems.

Let me know if that makes sense, I plan on closing this issue in a week if I don't hear back 😄

Celforyon commented 5 years ago

It works, indeed. Thanks!