examples/server.js
function startInlineServices() {
  // Provide a webhook definition
  var hook = {
    name: 'Inline Sample',
    events: ['message.sent'],
    path: '/inline_sample_message_sent',
  };

  // Register this webhook with Layer's Services
  webhooksServices.register({
    secret: SECRET,
    url: HOST + ':' + PORT,
    hooks: [hook]
  });

  // Listen for events from Layer's Services, and call our callbackAsync with each event
  webhooksServices.listen({
    expressApp: app,
    secret: SECRET,
    hooks: [hook]
  }, redis);

  // Setup your callback to handle the webhook events
  queue.process(hook.name, 50, function(job, done) {
    console.log(new Date().toLocaleString() + ': Inline Sample: Message Received from ' + (job.data.message.sender.user_id || job.data.message.sender.name));
    done();
  });
}
function startInlineServices() {
  // Provide a webhook definition
  var hook = {
    name: 'Inline Sample',
    events: ['message.sent'],
    path: '/inline_sample_message_sent',
  };

  // Register this webhook with Layer's Services
  webhooksServices.register({
    secret: SECRET,
    url: HOST + ':' + PORT,
    hooks: [hook]
  });

  // Listen for events from Layer's Services, and call our callbackAsync with each event
  webhooksServices.listen({
    expressApp: app,
    secret: SECRET,
    hooks: [hook]
  }, redis);

  // Setup your callback to handle the webhook events
  queue.process(hook.name, 50, function(job, done) {
    console.log(new Date().toLocaleString() + ': Inline Sample: Message Received from ' + (job.data.message.sender.user_id || job.data.message.sender.name));
    done();
  });
}
function startInlineServices ( ) { // Provide a webhook definition var hook = { name : 'Inline Sample' , events : [ 'message.sent' ] , path : '/inline_sample_message_sent' , } ; // Register this webhook with Layer's Services webhooksServices . register ( { secret : SECRET , url : HOST + ':' + PORT , hooks : [ hook ] } ) ; // Listen for events from Layer's Services, and call our callbackAsync with each event webhooksServices . listen ( { expressApp : app , secret : SECRET , hooks : [ hook ] } , redis ) ; // Setup your callback to handle the webhook events queue . process ( hook . name , 50 , function ( job , done ) { console . log ( new Date ( ) . toLocaleString ( ) + ': Inline Sample: Message Received from ' + ( job . data . message . sender . user_id || job . data . message . sender . name ) ) ; done ( ) ; } ) ; }
Example shows quick and simple setup of a webhooks service.
This example shows a single inline service that logs new messages.
Example shows quick and simple setup of a webhooks service . This example shows a single inline service that logs new messages .