Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

hapi-ham

Package Overview
Dependencies
Maintainers
2
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-ham

hapi answering machine

latest
Source
npmnpm
Version
6.2.1
Version published
Weekly downloads
9
-55%
Maintainers
2
Weekly downloads
 
Created
Source

hapi-ham

hapi answering machine

Usage

'use strict';

const Hapi = require('hapi');

// Create a server with a host and port
const server = new Hapi.Server();
server.connection({
  port: 8000
});

// Register hapi-ham plugin
server.register({
  register: require('hapi-ham'),
  options: {
    provider: 'facebook-messenger',
    access_token: '<facebook_page_token>'
    //debug: true
  }
}, (err) => {

  if (err) {
    throw err
  }

  server.route({
    method: 'GET',
    path: '/',
    handler: function (request, reply) {
      return reply.validateWebhook()
    }
  })

  // Add the route
  server.route({
    method: 'POST',
    path: '/',
    handler: function (request, reply) {
      const template = {
        text: `Received message: ${request.event.message.text}`
      }
      return reply.message(template)
    }
  })

  // Start the server
  server.start((err) => {

    if (err) {
      throw err;
    }
    console.log('Server running at:', server.info.uri)
  })
})

FAQs

Package last updated on 06 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts