New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wingbot-botservice

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wingbot-botservice

Microsoft BotService connector for wingbot.ai

  • 3.10.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
2
Weekly downloads
 
Created
Source

Microsoft BotService plugin for wingbot.ai

const { Router, Bot } = require('wingbot');
const { BotService } = require('wingbot-botservice');

const bot = new Bot();

const processor = new Processor(bot);

const bs = new BotService(processor, {
    appId: '123',
    appSecret: '456'
});

// the route
module.exports.bot = async (req, res) => {
    const { body, headers } = req;

    await bs.verifyRequest(body, headers);

    await bs.processEvent(body);
};

Using backchannel for sending postBacks to the bot

const directLine = new DirectLine();
directLine.postActivity({
    type:'event',
    name:'postBack',
    from:{ id: botserviceUserId },
    value:{ action: 'action-path', data: {/* optional */} }
});

API

Classes

BotService

BotService connector for wingbot.ai

Functions

botServiceQuickReplyPatch(bot, [startAction])function

Patch, which solves problem with BotFramework. Always, when conversationId is changed, middleware looks for matching quick replies from first text request. When there are some, it redirects user

BotService

BotService connector for wingbot.ai

Kind: global class

new BotService(processor, options, [senderLogger])

ParamTypeDefaultDescription
processorProcessorwingbot Processor instance
optionsObject
options.appIdstringbotservice client id
options.appSecretstringbotservice client secret
[options.grantType]stringboservice authentication grant_type
[options.scope]stringboservice authentication scope
[options.uri]stringboservice authentication uri
[options.welcomeAction]string | null"'start'"conversation start emits postback
[options.requestLib]functionrequest library replacement for testing
[options.overPublic]stringoverride public key for testing
[senderLogger]consoleoptional console like chat logger

botService.processEvent(body) ⇒ Promise.<Array.<{message:Object, pageId:string}>>

Process Facebook request

Kind: instance method of BotService
Returns: Promise.<Array.<{message:Object, pageId:string}>> - - unprocessed events

ParamTypeDescription
bodybs.Activityevent body

botService.verifyRequest(body, headers) ⇒ Promise

Verify Facebook webhook event

Kind: instance method of BotService
Throws:

  • Error when authorization token is invalid or missing
ParamTypeDescription
bodyObjectparsed request body
headersObjectrequest headers

botServiceQuickReplyPatch(bot, [startAction]) ⇒ function

Patch, which solves problem with BotFramework. Always, when conversationId is changed, middleware looks for matching quick replies from first text request. When there are some, it redirects user

Kind: global function
Returns: function - - the middleware

ParamTypeDefaultDescription
botRouterchatbot itself
[startAction]string"start"start action to fetch quick replies

Example

const { Router } = require('wingbot');
const { botServiceQuickReplyPatch } = require('wingbot-botservice');

const bot = new Router();

// attach as first
const patch = botServiceQuickReplyPatch(bot, 'start');
bot.use(patch);

bot.use('start', (req, res) => {
    res.text('Hello', {
        goto: 'Go to'
    });
});

Keywords

FAQs

Package last updated on 26 Mar 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc