Classes

Request

Instance of {Request} class is passed as first parameter of handler (req)

Typedefs

Entity : object
Intent : object
Action : object
IntentAction : object
QuickReply : object
 

Request

Instance of {Request} class is passed as first parameter of handler (req)

Kind: global class

 

request.params

Kind: instance property of Request
Properties

Name Type Description
params object plugin configuration
 

request.timestamp

Kind: instance property of Request
Properties

Name Type
timestamp number \ null
 

request.senderId

Kind: instance property of Request
Properties

Name Type Description
senderId string sender.id from the event
 

request.recipientId

Kind: instance property of Request
Properties

Name Type Description
recipientId string recipient.id from the event
 

request.pageId

Kind: instance property of Request
Properties

Name Type Description
pageId string page identifier from the event
 

request.state

Kind: instance property of Request
Properties

Name Type Description
state object current state of the conversation
 

request.subscribtions

Kind: instance property of Request
Properties

Name Type Description
state Array.<string> list of subscribed tags
 

request.entities

Kind: instance property of Request
Properties

Name Type Description
entities Array.<Entity> list of entities
 

request.intents

Kind: instance property of Request
Properties

Name Type Description
intents Array.<Intent> list of resolved intents
 

request.event : object

The original messaging event

Kind: instance property of Request

 

request.isStandby() ⇒ boolean

Returns true, if the incomming event is standby

Kind: instance method of Request

 

request.aiActions() ⇒ Array.<IntentAction>

Get all matched actions from NLP intents

Kind: instance method of Request

 

request.aiActionsForQuickReplies([limit], [aiActions], [overrideAction]) ⇒ Array.<QuickReply>

Covert all matched actions for disambiguation purposes

Kind: instance method of Request
Params

 

request.hasAiActionsForDisambiguation(minimum) ⇒ boolean

Returns true, if there is an action for disambiguation

Kind: instance method of Request
Params

  • minimum number = 1
 

request.intent(getDataOrScore) ⇒ null | string | Intent

Returns intent, when using AI

Kind: instance method of Request
Params

  • getDataOrScore boolean | number = false - score limit or true for getting intent data
 

request.entity(name, [sequence]) ⇒ number | string | null

Get matched entity value

Kind: instance method of Request
Params

  • name string - name of requested entity
  • [sequence] number = 0 - when there are more then one entity
 

request.isAttachment() ⇒ boolean

Checks, when message contains an attachment (file, image or location)

Kind: instance method of Request

 

request.isImage([attachmentIndex], [includingStickers]) ⇒ boolean

Checks, when the attachment is an image, but not a sticker

Kind: instance method of Request
Params

  • [attachmentIndex] number = 0 - use, when user sends more then one attachment
  • [includingStickers] boolean = false - return true, when the image is also a sticker
 

request.isFile([attachmentIndex]) ⇒ boolean

Checks, when the attachment is a file

Kind: instance method of Request
Params

  • [attachmentIndex] number = 0 - use, when user sends more then one attachment
 

request.hasLocation() ⇒ boolean

Checks for location in attachments

Kind: instance method of Request

 

request.getLocation() ⇒ null | Object

Gets location coordinates from attachment, when exists

Kind: instance method of Request
Example

const { Router } = require('wingbot');

const bot = new Router();

bot.use('start', (req, res) => {
    res.text('share location?', [
        // location share quick reply
        { action: 'locAction', title: 'Share location', isLocation: true }
    ]);
});

bot.use('locAction', (req, res) => {
    if (req.hasLocation()) {
        const { lat, long } = req.getLocation();
        res.text(`Got ${lat}, ${long}`);
    } else {
        res.text('No location received');
    }
});
 

request.attachment([attachmentIndex]) ⇒ object | null

Returns whole attachment or null

Kind: instance method of Request
Params

  • [attachmentIndex] number = 0 - use, when user sends more then one attachment
 

request.attachmentUrl([attachmentIndex]) ⇒ string | null

Returns attachment URL

Kind: instance method of Request
Params

  • [attachmentIndex] number = 0 - use, when user sends more then one attachment
 

request.isMessage() ⇒ boolean

Returns true, when the request is text message, quick reply or attachment

Kind: instance method of Request

 

request.isQuickReply() ⇒ boolean

Check, that message is a quick reply

Kind: instance method of Request

 

request.isText() ⇒ boolean

Check, that message is PURE text

Kind: instance method of Request

 

request.isSticker([includeToTextStickers]) ⇒ boolean

Returns true, when the attachment is a sticker

Kind: instance method of Request
Params

  • [includeToTextStickers] boolean = false - including strickers transformed into a text
 

request.text([tokenized]) ⇒ string

Returns text of the message

Kind: instance method of Request
Params

  • [tokenized] boolean = false - when true, message is normalized to lowercase with -

Example

console.log(req.text(true)) // "can-you-help-me"
 

request.expected() ⇒ Action | null

Returns the request expected handler in case have been set last response

Kind: instance method of Request

 

request.expectedKeywords([justOnce])

Returns all expected keywords for the next request (just expected keywords)

Kind: instance method of Request
Params

  • [justOnce] boolean = false - - don't return already retained items

Example

bot.use('my-route', (req, res) => {
    res.setState(req.expectedKeywords());
});
 

request.expectedContext([justOnce], [includeKeywords]) ⇒ object

Returns current turn-around context (expected and expected keywords)

Kind: instance method of Request
Params

  • [justOnce] boolean = false - don't return already retained items
  • [includeKeywords] boolean = false - keep intents from quick replies

Example

bot.use('my-route', (req, res) => {
    res.setState(req.expectedContext());
});
 

request.quickReply([getData]) ⇒ null | string | object

Returns action or data of quick reply When getData is true, object will be returned. Otherwise string or null.

Kind: instance method of Request
Params

  • [getData] boolean = false

Example

typeof res.quickReply() === 'string' || res.quickReply() === null;
typeof res.quickReply(true) === 'object';
 

request.isPostBack() ⇒ boolean

Returns true, if request is the postback

Kind: instance method of Request

 

request.isReferral() ⇒ boolean

Returns true, if request is the referral

Kind: instance method of Request

 

request.isOptin() ⇒ boolean

Returns true, if request is the optin

Kind: instance method of Request

 

request.setAction(action, [data]) ⇒ Action | null | undefined

Sets the action and returns previous action

Kind: instance method of Request
Returns: Action | null | undefined - - previous action
Params

  • action string | Action | null
  • [data] object
 

request.action([getData]) ⇒ null | string

Returns action of the postback or quickreply

the order, where from the action is resolved

  1. referral
  2. postback
  3. optin
  4. quick reply
  5. expected keywords & intents
  6. expected action in state
  7. global or local AI intent action

Kind: instance method of Request
Params

  • [getData] boolean = false - deprecated

Example

typeof res.action() === 'string' || res.action() === null;
typeof res.actionData() === 'object';
 

request.actionData() ⇒ object

Returns action data of postback or quick reply

Kind: instance method of Request

 

request.getSetState() ⇒ object

Gets incomming setState action variable

Kind: instance method of Request
Example

res.setState(req.getSetState());
 

request.isConfidentInput() ⇒ boolean

Returns true, if previous request has been marked as confident using res.expectedConfidentInput()

It's good to consider this state in "analytics" integrations.

Kind: instance method of Request

 

request.postBack([getData]) ⇒ null | string | object

Returns action or data of postback When getData is true, object will be returned. Otherwise string or null.

Kind: instance method of Request
Params

  • [getData] boolean = false

Example

typeof res.postBack() === 'string' || res.postBack() === null;
typeof res.postBack(true) === 'object';
 

Entity : object

Kind: global typedef
Properties

Name Type
entity string
value string
score number
 

Intent : object

Kind: global typedef
Properties

Name Type
intent string
score number
[entities] Array.<Entity>
 

Action : object

Kind: global typedef
Properties

Name Type
action string
data object
[setState] object \ null
 

IntentAction : object

Kind: global typedef
Properties

Name Type
action string
intent Intent
sort number
local boolean
aboveConfidence boolean
[winner] boolean
[title] string \ function
meta object
[meta.targetAppId] string
[meta.targetAction] string \ null
 

QuickReply : object

Kind: global typedef
Properties

Name Type
action string
title *

results matching ""

    No results matching ""