Git Product home page Git Product logo

mattermost-bot-sample-golang's Introduction

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

Setup Server Environment

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

This Bot Sample was tested with Mattermost server version 3.5.0.

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

./bin/platform -create_team -team_name="botsample" -email="[email protected]" -password="password1" -username="samplebot"

3 - Create the user account the Bot will run as.

./bin/platform -create_user -team_name="botsample" -email="[email protected]" -password="password1" -username="samplebot"

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

./bin/platform -create_user -team_name="botsample" -email="[email protected]" -password="password1" -username="bill"

5 - (Optional) Give bill system_admin permissions.

./bin/platform -assign_role -email="[email protected]" -role="system_admin"

6 - Log in to http://localhost:8065 as bill and verify the account was created successfully. Then, navigate to the botsample team you created in step 2 to interact with the Bot.

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 - Start the Bot.

make run

You can verify the Bot is running when

  • Server detected and is running version 3.X.X appears on the command line.
  • Mattermost Bot Sample has started running is posted in the Debugging For Sample Bot channel.

Test the Bot

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

2 - Join the Debugging For Sample Bot channel.

3 - Post a message in the channel such as are you running? to see if the Bot responds. You should see a response similar to Yes I'm running if the Bot is running.

Stop the Bot

1 - In the terminal window, press CTRL+C to stop the bot. You should see Mattermost Bot Sample has stopped running posted in the Debugging For Sample Bot channel.

mattermost-bot-sample-golang's People

Contributors

coreyhulen avatar hmhealey avatar jasonblais avatar pneisen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.