Giter Site home page Giter Site logo

hapi-server's Introduction

  1. In the command line, run the following command to start the server:
  • $ git clone [email protected]:saturninoabril/hapi-server.git or git clone https://github.com/saturninoabril/hapi-server

  • $ cd hapi-server

  • $ npm install

  • $ node server.js - default response is without username and icon_url.

    :: If wanted to set the username in the response, run the server like WITH_USERNAME=true node server.js

    :: If wanted to set the icon_url in the response, run the server like WITH_ICON_URL=true node server.js

    :: If wanted to set both username and icon_url in the response, run the server like WITH_ICON_URL=true WITH_USERNAME=true node server.js

    :: Server has started successfully when the console printed Server running at: http://localhost:3000

  1. (Optional) Setup a tunnel so your local hapi-server instance can be accessed outside your local network
  • download ngrok and follow its setup instruction at https://ngrok.com/download
  • run at the command line: $ ./ngrok http 3000
  • take note of the forwarding URL (e.g. http://ad3cc10f.ngrok.io)
  1. Setup outgoing webhook of Mattermost server, following the documentation:
  1. Verify that the incoming payload & headers are received by the hapi-server from Mattermost server.
  • observe the payload being printed in console for every hook.

  • verify the payload you're expecting to receive.

    :: Sample incoming payload:

{
    token: 'y41bbi8p5bfbmgioiajeyx4g7e',
    team_id: 'syukb1muop8xuei5k8r66ted5o',
    team_domain: 'ad-1',
    channel_id: 'y19oxu5h17r1x8fnu7cm4zkq3w',
    channel_name: 'outgoing',
    timestamp: 1533212631376,
    user_id: 'jr5bqb3izj8u3r7tu81oti1g8h',
    user_name: 'user-1',
    post_id: 'f3wii843hpg5brai8jdcp9rwza',
    text: 'another',
    trigger_word: 'another',
    file_ids: ''
}
:: Sample incoming headers:
{
    host: 'ad3cc10f.ngrok.io',
    'user-agent': 'Go-http-client/1.1',
    'content-length': '347',
    accept: 'application/json',
    'content-type': 'application/json',
    'accept-encoding': 'gzip',
    'x-forwarded-for': '54.188.242.58'
}
  1. Verify the outgoing response from hapi-server to Mattermost server.
  • observe the outgoing response being printed in console for every hook.

    :: Sample outgoing response:

{
    text: '#### Outgoing Webhook Response\n - token: "y41bbi8p5bfbmgioiajeyx4g7e"\n - trigger_word: "another"\n - text: "another"\n - channel_name: "outgoing"\n - team_domain: "ad-1"\n',
    username: '',
    icon_url: 'https://docs.mattermost.com/_images/icon-76x76.png',
    type: '',
    response_type: 'in_channel'
}

hapi-server's People

Contributors

saturninoabril 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.