• Stars
    star
    170
  • Rank 217,101 (Top 5 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 8 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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.

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.

More Repositories

1

mattermost

Mattermost is an open source platform for secure collaboration across the entire software development lifecycle..
TypeScript
28,319
star
2

focalboard

Focalboard is an open source, self-hosted alternative to Trello, Notion, and Asana.
TypeScript
19,506
star
3

mattermost-webapp

Archived web app of Mattermost. Moved to the monorepo: https://github.com/mattermost/mattermost
TypeScript
2,291
star
4

desktop

Mattermost Desktop application for Windows, Mac and Linux
TypeScript
1,921
star
5

mattermost-mobile

Next generation iOS and Android apps for Mattermost in React Native
TypeScript
1,898
star
6

mattermost-docker

Deprecated
Shell
964
star
7

docker

Install Mattermost server via Docker
Shell
294
star
8

mattermost-push-proxy

Go
217
star
9

docs

Mattermost documentation
Python
205
star
10

mattermost-redux

Redux for Mattermost
JavaScript
200
star
11

mattermost-plugin-jitsi

Jitsi plugin for Mattermost πŸ”Œ
Go
183
star
12

mattermost-android-classic

Mattermost app for Android phones and tablets
Java
175
star
13

mattermost-ios-classic

Mattermost iOS application source code
Swift
156
star
14

mattermost-helm

Mattermost Helm charts for Kubernetes
Smarty
153
star
15

openops

Open source stack for applying AI to workflows in secure environments
Shell
138
star
16

mattermost-plugin-github

GitHub plugin for Mattermost
Go
131
star
17

mattermost-plugin-gitlab

GitLab plugin for Mattermost
JavaScript
131
star
18

mattermost-plugin-autolink

Automatically rewrite text matching a regular expression into a markdown link.
Go
123
star
19

mattermost-operator

Mattermost Operator for Kubernetes
Go
114
star
20

mattermost-plugin-ai

Mattermost plugin for LLMs
Go
110
star
21

mattermost-plugin-zoom

Zoom plugin for Mattermost πŸ”Œ
Go
105
star
22

mattermost-plugin-starter-template

Build scripts and templates for writing Mattermost plugins.
Go
98
star
23

mattermost-plugin-jira

JIRA plugin for Mattermost πŸ”Œ
Go
97
star
24

react-native-paste-input

React Native TextInput replacement to allow pasting files
Objective-C
82
star
25

xml-roundtrip-validator

Go
79
star
26

mattermost-plugin-calls

TypeScript
78
star
27

mattermost-api-reference

Mattermost API reference documentation.
HTML
76
star
28

mattermost-integration-gitlab

GitLab Integration Service for Mattermost
Python
75
star
29

mattermost-developer-documentation

Mattermost developer documentation.
CSS
71
star
30

mattermost-plugin-playbooks

Create and manage pre-built, configurable checklists that define a repeatable process for teams to achieve specific and predictable outcomes.
TypeScript
65
star
31

mattermost-plugin-demo

A demo of what Mattermost plugins can do.
Go
64
star
32

mattermost-plugin-memes

Add culture to your Mattermost with memes πŸ”Œ
Go
61
star
33

mattermost-plugin-todo

Mattermost plugin for tracking to do items
JavaScript
60
star
34

mattermost-load-test

[DEPRECATED] replaced by https://github.com/mattermost/mattermost-load-test-ng
Go
59
star
35

mattermost-cloud

Tools and services for running Mattermost Cloud ☁️
Go
58
star
36

mattermost-plugin-welcomebot

Go
57
star
37

mattermost-docker-preview

Mattermost Preview Docker Image
Dockerfile
57
star
38

mattermost-load-test-ng

Mattermost next generation loadtest agent
Go
53
star
39

mattermost-data-warehouse

Python
53
star
40

mattermost-cloud-monitoring

HCL
48
star
41

mattermost-plugins

This project hosts plugins built by Mattermost staff and community.
45
star
42

mattermost-handbook

Mattermost Community and Staff Handbook
43
star
43

mattermost-driver-javascript

Javascript library for interacting with the Mattermost API
JavaScript
42
star
44

action-mattermost-notify

GitHub Action for sending a notification to a Mattermost channel
Go
38
star
45

mattermost-marketplace

The stateless HTTP service backing the Mattermost marketplace.
Go
37
star
46

mattermost-plugin-autotranslate

Go
36
star
47

mattermost-plugin-custom-attributes

Mattermost plugin for adding custom attributes to users!
Go
35
star
48

mattermost-heroku

Run Mattermost on Heroku
Shell
34
star
49

morph

Go
32
star
50

mattermost-plugin-google-calendar

Mattermost Google Calendar Plugin
TypeScript
32
star
51

mattermost-plugin-apps

Powers the Mattermost App Framework
Go
31
star
52

mattermost-plugin-antivirus

Antivirus plugin for scanning files uploaded to Mattermost
Go
30
star
53

mattermost-plugin-jenkins

A Mattermost plugin to interact with Jenkins
Go
30
star
54

mattermost-plugin-agenda

Mattermost plugin to handle meeting agendas
Go
29
star
55

react-native-network-client

React Native network client by Mattermost
TypeScript
29
star
56

mattermost-integration-giphy

Giphy Integration Service for Mattermost
Python
27
star
57

mattermost-interactive-post-demo

Interactive post demo for Mattermost
Python
27
star
58

mattermost-plugin-email-reply

Go
26
star
59

mattermost-ai-framework

The Mattermost AI Framework
TypeScript
25
star
60

mattermost-plugin-walltime

Timezone Message Convert for Mattermost πŸ•› πŸ•’ πŸ•• πŸ•˜
JavaScript
23
star
61

mattermost-webrtc

Dockerfile
22
star
62

mattermost-omnibus

A simple way to install Mattermost.
Go
21
star
63

rtcd

Go
18
star
64

logr

Fully asynchronous, structured, pluggable logging for Go.
Go
17
star
65

mattermost-plugin-aws-SNS

Plugin that receives SNS notification from Alerts created by AWS CloudWatch and sent via AWS SNS
Go
17
star
66

mattermost-browser-extension

Demo Chrome extension for Mattermost 5.2+
JavaScript
16
star
67

chewbacca

Chewbacca GitHub Bot
Go
16
star
68

mattermost-plugin-skype4business

Go
15
star
69

matterbuild

Matterbuild - An internal Mattermost chatops tool for generating Mattermost releases
Go
14
star
70

mattermost-plugin-docup

Mattermost plugin for marking messages for documentation.
JavaScript
14
star
71

mattermost-govet

Go
14
star
72

mattermost-plugin-profanity-filter

A profanity filter plugin.
Go
14
star
73

matrix-as-mm

Matrix ↔️ Mattermost bridge
PLpgSQL
13
star
74

mattermost-plugin-confluence

A Mattermost Plugin to receive events from Confluence
Go
13
star
75

mattermost-plugin-msteams-meetings

Mattermost Plugin for Microsoft Teams Meetings
Go
12
star
76

mattermost-oauth2-client-sample

Sample app for Mattermost OAuth2 and App Center
JavaScript
12
star
77

quality-assurance

Issues and test assignments for QA Contributors/Community
11
star
78

mattermost-plugin-msteams

Go
11
star
79

builder

Mattermost builder
Go
11
star
80

mattermost-app-zendesk

Zendesk App for Mattermost
TypeScript
11
star
81

dynamic-virtualized-list

Dynamic virtualized list
JavaScript
11
star
82

mattermost-plugin-api

A hackathon project to explore reworking the Mattermost Plugin API.
Go
11
star
83

mattermost-mattermod

Go
11
star
84

react-native-emm

React Native package for EMM managed configurations
TypeScript
10
star
85

mattermost-looker

LookML
10
star
86

mattermost-plugin-mscalendar

Mattermost plugin for Microsoft Office365
Go
10
star
87

dbcmp

database comparison tool
Go
10
star
88

mattermost-hackathon-nov2019

10
star
89

mattermost-app-examples

Examples for the Mattermost App Framework
Go
10
star
90

mattermost-utilities

JavaScript
9
star
91

mattermost-developer-kit

Command line tool for generating Mattermost integration and plugin templates
JavaScript
9
star
92

mmetl

Go
8
star
93

mattermost-plugin-webex

Go
8
star
94

mattermost-plugin-cloud

Go
8
star
95

compass-components

[DEPRECATED] Compass Components is a shared component library used to build appealing user interfaces from scratch with ease. It's based on the Mattermost Design style guide called the Compass Design System.
TypeScript
8
star
96

perseus

Multiplex connections
Go
7
star
97

mattermost-app-nextcloud

Nextcloud App for Mattermost
Go
7
star
98

mattermost-plugin-demo-creator

Go
7
star
99

mattermost-plugin-circleci

Mattermost Plugin for CircleCI SaaS. Get notifications, trigger workflows, set env-vars directly from Mattermost
Go
6
star
100

mattermost-test-management

Mattermost Test Management, an open testing initiative.
TypeScript
6
star