GithubHelp home page GithubHelp logo

henriwi / hubot-mattermost Goto Github PK

View Code? Open in Web Editor NEW

This project forked from renanvicente/hubot-mattermost

0.0 1.0 0.0 11 KB

A hubot adapter for Mattermost

License: MIT License

CoffeeScript 100.00%

hubot-mattermost's Introduction

Mattermost logo

Downloads Version Licence

hubot-mattermost

Hubot adapter for Mattermost. Enables to add a Hubot bot to Mattermost.

Getting your bot connected to Mattermost

Here is a sample run:

picture of a sample interaction with mattermost

Installation

  • Follow the "Getting Started With Hubot" guide to get a local installation of Hubot
  • When you run the command yo hubot it should ask for an adapter, input "mattermost" so it can download this adapter automatically for you
  • Create an incoming webhook and outgoing webhook integration in your mattermost. You can follow the instructions on Incoming Webhooks and Outgoing Webhooks to setup.
  • Set the environment variables MATTERMOST_ENDPOINT, MATTERMOST_INCOME_URL and MATTERMOST_TOKEN based on your mattermost configuration.
  • It's important to remember that if you don't run Hubot alongside with Mattermost (locally) you must ensure that Mattermost instance can connect to the machine where Hubot is installed as it will be running on port 8080. This is due to Webhooks nature (both Incoming and Outgoing) where a HTTP POST will be send both ways for communication purposes (sending and receiving Mattermost/Hubot messages).

Example Installation

npm install -g yo generator-hubot
yo hubot --adapter mattermost

Environment variables

The adapter requires the following environment variables to be defined prior to run a Hubot instance:

  • MATTERMOST_ENDPOINT string, default: none - URI that you want hubot to listen, need to be the uri you specified when creating your outgoing webhook on mattermost. Example: if you create your outgoing webhook with http://127.0.0.1:8080/hubot/incoming you should set it with /hubot/incoming.
  • MATTERMOST_INCOME_URL string, default: none - Your incoming webhook url. Example: http://:/hooks/ncwc66caqf8d7c4gnqby1196qo
  • MATTERMOST_TOKEN string, default: none - Token from your outgoing webhook.

In addition, the following optional variables can be set:

  • MATTERMOST_CHANNEL string, default: none - Override the channel that you want to reply to.
  • MATTERMOST_ICON_URL string, default: none - If Enable Overriding of Icon from Webhooks is enabled you can set a url with the icon that you want for your hubot.
  • MATTERMOST_HUBOT_USERNAME string, default: none - If Enable Overriding of Usernames from Webhooks you can set a custom username to show in mattermost.
  • MATTERMOST_SELFSIGNED_CERT boolean, default: none - If true it will ignore if MATTERMOST_ENDPOINT has a self signed certificate.

Example for Environment variables

export MATTERMOST_ENDPOINT=/hubot/incoming # listen endpoint
export MATTERMOST_CHANNEL=town-square # optional: if you want to override your channel
export MATTERMOST_INCOME_URL=http://<your mattermost instance>:<port>/hooks/ncwc66caqf8d7c4gnqby1196qo # your mattermost income url
export MATTERMOST_TOKEN=oqwx9d4khjra8cw3zbis1w6fqy # your mattermost token
export MATTERMOST_ICON_URL=https://s3-eu-west-1.amazonaws.com/renanvicente/toy13.png # optional: if you want to override hubot icon
export MATTERMOST_HUBOT_USERNAME="matterbot" # optional: if you want to override hubot name
export MATTERMOST_SELFSIGNED_CERT=true # optional: if you want to ignore self signed certificate

Example with Hubot sending to multiple channels

Although Mattermost doesn't allow multiple channels on a single Incoming/Outgoing hook you can do the following in order to allow Hubot to listen to multiple channels:

  • Create an Outgoing Hook for each channel to wish to have Hubot. That will give you multiple tokens
  • Set MATTERMOST_TOKEN global variable with multiple tokens separated by comma

Example:

export MATTERMOST_ENDPOINT=/hubot/incoming # listen endpoint
export MATTERMOST_INCOME_URL=http://localhost:8065/hooks/3eo1wjwyxibnmd5rsusk4h4pgh # your mattermost income url
export MATTERMOST_TOKEN="epboqd78ufyi58nxktgzq9zpho,7ftco7zg5fdkixw7j3okmuo3eo" # your mattermost token for **each Channel**
export MATTERMOST_ICON_URL=https://s3-eu-west-1.amazonaws.com/renanvicente/toy13.png # optional: if you want to override hubot icon
export MATTERMOST_HUBOT_USERNAME="matterbot" # optional: if you want to override hubot name

Note that there is no need to create multiple Incoming Hooks as we can use a single Incoming Hook but specify what channel we want to send the message to as described in the documentation.

Run hubot with mattermost adapter.

bin/hubot -a mattermost

License

The MIT License. See LICENSE file.

hubot-mattermost's People

Contributors

heitorlessa avatar renanvicente 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.