Coder Social home page Coder Social logo

personium-ex-slack-messenger's Introduction

personium-ex-slack-messenger

About

This is a Personium's Engine extension for sending Slack message to specified channel.

Installation

Please see Setup Engine Extensions.

Usage

  1. Clone this repository.
  2. Compile the source codes to Ext_Slack.jar by maven command mvn package -DskipTests=true.
  3. Set the jar module Ext_Slack.jar into the Engine Extension directory in Personium application server. Default directory is /personium/personium-engine/extensions/.
  4. Restart tomcat process.
  5. Set an Engine Service which call this slack-message function.

Sample script is below.

function(request) {
    var token = "xoxb-xxxx";
    var defaultChannel = "random";

    var slack = new _p.extension.Slack();
    slack.setConfig(token, defaultChannel);

    slack.sendMessage("Hello, I am persoinum slack bot in default channel");
    slack.sendMessageToUser("Hello, I am persoinum slack bot: ", "${user}");
    slack.sendMessageToChannel("Hello, I am persoinum slack bot: ", "${channel}");

    // with proxy 
    // var slack = new _p.extension.Slack();
    // var proxyConf = {
    //    host: "your.proxy.host", 
    //    port: "8080",
    //    user: "proxy.user",
    //    password: "proxy.password",
    // };
    // slack.setConfig(token, defaultChannel, proxyConf);
    // slack.sendMessage("Hello, I am persoinum slack bot in random channel with proxy");

    return {
        status : 200,
        headers : {"Content-Type":"application/json"},
        body : ['Complete to send slack message!']
    };
}
  1. Grant the D:exec privilege to using role and call Engine Execution API by the user who has this role.

Test

  1. If you use conf file, edit property file conf/Ext_Slack.sample.properties to set token and channel, rename and save conf/Ext_Slack.properties. And run the test.
  2. If you use environments, when you start to run the test, you can set -D environments such as -Dio.personium.engine.extension.Slack.apitoken="~" -Dio.per.., .

Use slack bot api library

Simple-slack-api

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

personium-ex-slack-messenger's People

Contributors

ka2jun8 avatar nisiguti avatar sawamiwataru avatar tochi-y 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.