百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

mattermost-bot-sample-golang

> 编程语言
开源

Mattermost Bot 示例概述 此示例 Bot 展示了如何使用 Mattermost Go 驱动程序与 Mattermost 服务器进行交互,监听事件,以及如何使用 Mattermost Go 编写自定义 Bot。

185 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Mattermost Bot 示例概述 此示例 Bot 展示了如何使用 Mattermost Go 驱动程序与 Mattermost 服务器进行交互,监听事件,以及如何使用 Mattermost Go 编写自定义 Bot。

Mattermost Bot Sample

Overview

This sample Bot shows how to use the Mattermost Go driver to interact with a Mattermost server, listen to events and respond to messages. Documentation for the Go driver can be found here.

Highlights of APIs used in this sample:

  • Log in to the Mattermost server
  • Create a channel
  • Modify user attributes
  • Connect and listen to WebSocket events for real-time responses to messages
  • Post a message to a channel

This Bot Sample was tested with Mattermost server version 7.5.2.

Setup Server Environment

Via Docker And Docker-Compose

1 - Ensure Docker and Docker-Compose are installed on your system.

2 - Run docker-compose up -d --build and the mattermost client will be built and will expose the port 8065 to your system's localhost.

3 - Run ./add_users.sh. The login information for the Mattermost client will be printed.

4 - Log into your mattermost instance using these credentials and create a bot account following these instructions.

5 - Copy example.env to .env and fill in the bot token (obtained from the previous step), team name, etc. Alternatively, just provide your credentials as environment variables.

5 - Start the Bot.

make run

You can verify the Bot is running when

  • Logged in to mattermost appears on the command line.
  • Hi! I am a bot. is posted in your specified channel.

See "Test the Bot" for testing instructions

Via Direct System Install/Setup

1 - Install or upgrade to Mattermost server version 3.10+, and verify that the Mattermost server is running on http://localhost:8065.

On the commands below, if you are running Mattermost server version 5.0 or later, use ./bin/mmctl. If you are running version 4.10 or earlier, use ./bin/platform.

Learn more about the mmctl CLI tool in the Mattermost documentation.

2 - Create a team for the Bot to run. If you have an existing team, you may skip this step and replace botsample with your existing team in subsequent steps.

./bin/mmctl team create --name botsample --display_name "Sample Bot playground" --email "[email protected]"

3 - Create a user, bill, which we will use to log in and interact with the Bot.

./bin/mmctl user create --email="[email protected]" --password="Password1!" --username="bill"

4 - (Optional) Give bill system_admin permissions.

./bin/mmctl roles system_admin bill

5 - Log in to http://localhost:8065 as bill and verify the account was created successfully.

6 - Create a bot account following these instructions.

7 - Copy example.env to .env and fill in the bot token (obtained from the previous step), team name, etc. Alternatively, just provide your credentials as environment variables.

Setup Bot Development Environment

1 - Follow the Developer Machine Setup instructions to setup the bot development environment.

2 - Clone the GitHub repository to run the sample.

bash
git clone https://github.com/mattermost/mattermost-bot-sample-golang.git
cd mattermost-bot-sample-golang

3 - Log into your mattermost instance using these credentials and create a bot account following these instructions.

4 - Copy example.env to .env and fill in the bot token (obtained from the previous step), team name, etc. Alternatively, just provide your credentials as environment variables.

5 - Run with

make run

You can verify the Bot is running when

  • Logged in to mattermost appears on the command line.
  • Hi! I am a bot. is posted in your specified channel.

Test the Bot

1 - Log in to the Mattermost server as [email protected] and Password1!.

2 - Join your specified channel.

3 - Post a message in the channel such as hello? to see if the Bot responds. You should see a response if the Bot is running.

Stop the Bot

1 - In the terminal window, press CTRL+C to stop the bot.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gohacktoberfest

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言