Classes
Constants
- FEATURE_VOICE :
string
channel supports voice messages
- FEATURE_SSML :
string
channel supports SSML voice messages
- FEATURE_PHRASES :
string
channel supports expected phrases messages
- FEATURE_TEXT :
string
channel supports text communication
- FEATURE_TRACKING :
string
channel supports tracking protocol
- FEATURE_VOICE :
string
channel supports voice messages
- FEATURE_SSML :
string
channel supports SSML voice messages
- FEATURE_PHRASES :
string
channel supports expected phrases messages
- FEATURE_TEXT :
string
channel supports text communication
- FEATURE_TRACKING :
string
channel supports tracking protocol
Typedefs
- Entity :
object
- Intent :
object
- Action :
object
- IntentAction :
object
- QuickReply :
object
- QuickReplyDisambiguation :
object
- RequestOrchestratorOptions :
object
- TextAlternative :
object
- Attachment :
object
- AiSetStateOption :
number
Request
Kind: global class
- Request
- new Request()
- new Request(event, state, pageId, globalIntents, [orchestratorOptions], [configuration])
- .params
- .attachments :
Array.<Attachment>
- .timestamp :
number
|null
- .senderId :
string
- .recipientId :
string
- .pageId :
string
- .state :
S
- .features :
Array.<string>
- .subscribtions :
Array.<string>
- .entities :
Array.<Entity>
- .intents :
Array.<Intent>
- ._orchestratorClientOptions :
OrchestratorClientOptions
- .configuration :
C
- .event :
object
- .AI_SETSTATE :
enum
- .supportsFeature(feature) ⇒
boolean
- .isStandby() ⇒
boolean
- .aiActions([local]) ⇒
Array.<IntentAction>
- .aiActionsForQuickReplies([limit], [aiActions], [overrideAction]) ⇒
Array.<QuickReplyDisambiguation>
- .hasAiActionsForDisambiguation(minimum, [local]) ⇒
boolean
- .intent(getDataOrScore) ⇒
null
|string
|Intent
- .entity(name, [sequence]) ⇒
number
|string
|null
- .isAttachment() ⇒
boolean
- .isSetContext(varsToCheck)
- .getSetContext([includeContextSync]) ⇒
object
- .isImage([attachmentIndex], [includingStickers]) ⇒
boolean
- .isFile([attachmentIndex]) ⇒
boolean
- .hasLocation() ⇒
boolean
- .getLocation() ⇒
null
|Object
- .attachment([attachmentIndex]) ⇒
object
|null
- .attachmentUrl([attachmentIndex]) ⇒
string
|null
- .isMessage() ⇒
boolean
- .isQuickReply() ⇒
boolean
- .isText() ⇒
boolean
- .isSticker([includeToTextStickers]) ⇒
boolean
- .text([tokenized]) ⇒
string
- .textAlternatives() ⇒
Array.<TextAlternative>
- .expected() ⇒
Action
|null
- .expectedKeywords([justOnce])
- .expectedContext([justOnce], [includeKeywords]) ⇒
object
- .quickReply([getData]) ⇒
null
|string
|object
- .isPostBack() ⇒
boolean
- .isReferral() ⇒
boolean
- .isOptin() ⇒
boolean
- .setAction(action, [data]) ⇒
Action
|null
|undefined
- .action([getData]) ⇒
null
|string
- .actionData() ⇒
object
- .getSetState(keysFromAi) ⇒
object
- .isConfidentInput() ⇒
boolean
- .actionByAi() ⇒
string
|null
- .aiActionsWinner() ⇒
IntentAction
|null
- .postBack([getData]) ⇒
null
|string
|object
- .expectedEntities() ⇒
Array.<string>
new Request()
Instance of {Request} class is passed as first parameter of handler (req)
new Request(event, state, pageId, globalIntents, [orchestratorOptions], [configuration])
Param | Type |
---|---|
event | * |
state | S |
pageId | string |
globalIntents | Map |
[orchestratorOptions] | RequestOrchestratorOptions |
[configuration] | C |
request.params
Kind: instance property of Request
Properties
Name | Type | Description |
---|---|---|
params | object | plugin configuration |
Array.<Attachment>
request.attachments : Kind: instance property of Request
number
| null
request.timestamp : timestamp
Kind: instance property of Request
string
request.senderId : senderId sender.id from the event
Kind: instance property of Request
string
request.recipientId : recipientId recipient.id from the event
Kind: instance property of Request
string
request.pageId : pageId page identifier from the event
Kind: instance property of Request
S
request.state : current state of the conversation
Kind: instance property of Request
Array.<string>
request.features : features supported messaging features
Kind: instance property of Request
Array.<string>
request.subscribtions : state list of subscribed tags
Kind: instance property of Request
Array.<Entity>
request.entities : entities list of entities
Kind: instance property of Request
Array.<Intent>
request.intents : intents list of resolved intents
Kind: instance property of Request
OrchestratorClientOptions
request._orchestratorClientOptions : Kind: instance property of Request
C
request.configuration : Kind: instance property of Request
object
request.event : The original messaging event
Kind: instance property of Request
enum
request.AI_SETSTATE : Kind: instance enum of Request
Properties
Name | Type | Default |
---|---|---|
ONLY | AiSetStateOption | 1 |
INCLUDE | AiSetStateOption | 0 |
EXCLUDE | AiSetStateOption | -1 |
EXCLUDE_WITH_SET_ENTITIES | AiSetStateOption | -2 |
EXCLUDE_WITHOUT_SET_ENTITIES | AiSetStateOption | -3 |
boolean
request.supportsFeature(feature) ⇒ Returns true if a channel supports specified feature
Kind: instance method of Request
Param | Type |
---|---|
feature | string |
boolean
request.isStandby() ⇒ Returns true, if the incoming event is standby
Kind: instance method of Request
Array.<IntentAction>
request.aiActions([local]) ⇒ Get all matched actions from NLP intents
Kind: instance method of Request
Param | Type | Default |
---|---|---|
[local] | boolean | false |
Array.<QuickReplyDisambiguation>
request.aiActionsForQuickReplies([limit], [aiActions], [overrideAction]) ⇒ Covert all matched actions for disambiguation purposes
Kind: instance method of Request
Param | Type | Default |
---|---|---|
[limit] | number | 5 |
[aiActions] | Array.<IntentAction> |
|
[overrideAction] | string | null |
boolean
request.hasAiActionsForDisambiguation(minimum, [local]) ⇒ Returns true, if there is an action for disambiguation
Kind: instance method of Request
Param | Type | Default |
---|---|---|
minimum | number | 1 |
[local] | boolean | false |
null
| string
| Intent
request.intent(getDataOrScore) ⇒ Returns intent, when using AI
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
getDataOrScore | boolean | number | false | score limit or true for getting intent data |
number
| string
| null
request.entity(name, [sequence]) ⇒ Get matched entity value
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
name | string | name of requested entity | |
[sequence] | number | 0 | when there are more then one entity |
boolean
request.isAttachment() ⇒ Checks, when message contains an attachment (file, image or location)
Kind: instance method of Request
request.isSetContext(varsToCheck)
Orchestrator: check, if the request updates only $context variables
- when no variables to check provided,
returns false when
set_context
is bundled within another conversational event
Kind: instance method of Request
Param | Type | Description |
---|---|---|
varsToCheck | Array.<string> | list of variables to check |
object
request.getSetContext([includeContextSync]) ⇒ Orchestrator: get current thread context update
Kind: instance method of Request
Returns: object
- - with §
prefixed keys
Param | Type | Default |
---|---|---|
[includeContextSync] | boolean | false |
boolean
request.isImage([attachmentIndex], [includingStickers]) ⇒ Checks, when the attachment is an image, but not a sticker
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[attachmentIndex] | number | 0 | use, when user sends more then one attachment |
[includingStickers] | boolean | false | return true, when the image is also a sticker |
boolean
request.isFile([attachmentIndex]) ⇒ Checks, when the attachment is a file
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[attachmentIndex] | number | 0 | use, when user sends more then one attachment |
boolean
request.hasLocation() ⇒ Checks for location in attachments
Kind: instance method of Request
null
| Object
request.getLocation() ⇒ 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');}});
object
| null
request.attachment([attachmentIndex]) ⇒ Returns whole attachment or null
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[attachmentIndex] | number | 0 | use, when user sends more then one attachment |
string
| null
request.attachmentUrl([attachmentIndex]) ⇒ Returns attachment URL
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[attachmentIndex] | number | 0 | use, when user sends more then one attachment |
boolean
request.isMessage() ⇒ Returns true, when the request is text message, quick reply or attachment
Kind: instance method of Request
boolean
request.isQuickReply() ⇒ Check, that message is a quick reply
Kind: instance method of Request
boolean
request.isText() ⇒ Check, that message is PURE text
Kind: instance method of Request
boolean
request.isSticker([includeToTextStickers]) ⇒ Returns true, when the attachment is a sticker
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[includeToTextStickers] | boolean | false | including strickers transformed into a text |
string
request.text([tokenized]) ⇒ Returns text of the message
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[tokenized] | boolean | false | when true, message is normalized to lowercase with - |
Example
console.log(req.text(true)) // "can-you-help-me"
Array.<TextAlternative>
request.textAlternatives() ⇒ Returns all text message alternatives including it's score
Kind: instance method of Request
Action
| null
request.expected() ⇒ 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
Param | Type | Default | Description |
---|---|---|---|
[justOnce] | boolean | false | - don't return already retained items |
Example
bot.use('my-route', (req, res) => {res.setState(req.expectedKeywords());});
object
request.expectedContext([justOnce], [includeKeywords]) ⇒ Returns current turn-around context (expected and expected keywords)
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[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());});
null
| string
| object
request.quickReply([getData]) ⇒ Returns action or data of quick reply
When getData
is true
, object will be returned. Otherwise string or null.
Kind: instance method of Request
Param | Type | Default |
---|---|---|
[getData] | boolean | false |
Example
typeof res.quickReply() === 'string' || res.quickReply() === null;typeof res.quickReply(true) === 'object';
boolean
request.isPostBack() ⇒ Returns true, if request is the postback
Kind: instance method of Request
boolean
request.isReferral() ⇒ Returns true, if request is the referral
Kind: instance method of Request
boolean
request.isOptin() ⇒ Returns true, if request is the optin
Kind: instance method of Request
Action
| null
| undefined
request.setAction(action, [data]) ⇒ Sets the action and returns previous action
Kind: instance method of Request
Returns: Action
| null
| undefined
- - previous action
Param | Type |
---|---|
action | string | Action | null |
[data] | object |
null
| string
request.action([getData]) ⇒ Returns action of the postback or quickreply
the order, where from the action is resolved
- referral
- postback
- optin
- quick reply
- expected keywords & intents
- expected action in state
- global or local AI intent action
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[getData] | boolean | false | deprecated |
Example
typeof res.action() === 'string' || res.action() === null;typeof res.actionData() === 'object';
object
request.actionData() ⇒ Returns action data of postback or quick reply
Kind: instance method of Request
object
request.getSetState(keysFromAi) ⇒ Gets incomming setState action variable
Kind: instance method of Request
Param | Type |
---|---|
keysFromAi | AiSetStateOption |
Example
res.setState(req.getSetState());
boolean
request.isConfidentInput() ⇒ 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
string
| null
request.actionByAi() ⇒ Returs action string, if there is an action detected by NLP
use rather designer's bounce feature instead of this pattern
Kind: instance method of Request
Example
const { Router } = require('wingbot');const bot = new Router();bot.use('question', (req, res) => {res.text('tell me your email').expected('email');});bot.use('email', async (req, res, postBack) => {if (req.actionByAi()) {await postBack(req.actionByAi(), {}, true);return;}res.text('thank you for your email');res.setState({ email: req.text() });});
IntentAction
| null
request.aiActionsWinner() ⇒ Returns full detected AI action
Kind: instance method of Request
null
| string
| object
request.postBack([getData]) ⇒ Returns action or data of postback
When getData
is true
, object will be returned. Otherwise string or null.
Kind: instance method of Request
Param | Type | Default |
---|---|---|
[getData] | boolean | false |
Example
typeof res.postBack() === 'string' || res.postBack() === null;typeof res.postBack(true) === 'object';
Array.<string>
request.expectedEntities() ⇒ Kind: instance method of Request
Request
Kind: global class
- Request
- new Request()
- new Request(event, state, pageId, globalIntents, [orchestratorOptions], [configuration])
- .params
- .attachments :
Array.<Attachment>
- .timestamp :
number
|null
- .senderId :
string
- .recipientId :
string
- .pageId :
string
- .state :
S
- .features :
Array.<string>
- .subscribtions :
Array.<string>
- .entities :
Array.<Entity>
- .intents :
Array.<Intent>
- ._orchestratorClientOptions :
OrchestratorClientOptions
- .configuration :
C
- .event :
object
- .AI_SETSTATE :
enum
- .supportsFeature(feature) ⇒
boolean
- .isStandby() ⇒
boolean
- .aiActions([local]) ⇒
Array.<IntentAction>
- .aiActionsForQuickReplies([limit], [aiActions], [overrideAction]) ⇒
Array.<QuickReplyDisambiguation>
- .hasAiActionsForDisambiguation(minimum, [local]) ⇒
boolean
- .intent(getDataOrScore) ⇒
null
|string
|Intent
- .entity(name, [sequence]) ⇒
number
|string
|null
- .isAttachment() ⇒
boolean
- .isSetContext(varsToCheck)
- .getSetContext([includeContextSync]) ⇒
object
- .isImage([attachmentIndex], [includingStickers]) ⇒
boolean
- .isFile([attachmentIndex]) ⇒
boolean
- .hasLocation() ⇒
boolean
- .getLocation() ⇒
null
|Object
- .attachment([attachmentIndex]) ⇒
object
|null
- .attachmentUrl([attachmentIndex]) ⇒
string
|null
- .isMessage() ⇒
boolean
- .isQuickReply() ⇒
boolean
- .isText() ⇒
boolean
- .isSticker([includeToTextStickers]) ⇒
boolean
- .text([tokenized]) ⇒
string
- .textAlternatives() ⇒
Array.<TextAlternative>
- .expected() ⇒
Action
|null
- .expectedKeywords([justOnce])
- .expectedContext([justOnce], [includeKeywords]) ⇒
object
- .quickReply([getData]) ⇒
null
|string
|object
- .isPostBack() ⇒
boolean
- .isReferral() ⇒
boolean
- .isOptin() ⇒
boolean
- .setAction(action, [data]) ⇒
Action
|null
|undefined
- .action([getData]) ⇒
null
|string
- .actionData() ⇒
object
- .getSetState(keysFromAi) ⇒
object
- .isConfidentInput() ⇒
boolean
- .actionByAi() ⇒
string
|null
- .aiActionsWinner() ⇒
IntentAction
|null
- .postBack([getData]) ⇒
null
|string
|object
- .expectedEntities() ⇒
Array.<string>
new Request()
Instance of {Request} class is passed as first parameter of handler (req)
new Request(event, state, pageId, globalIntents, [orchestratorOptions], [configuration])
Param | Type |
---|---|
event | * |
state | S |
pageId | string |
globalIntents | Map |
[orchestratorOptions] | RequestOrchestratorOptions |
[configuration] | C |
request.params
Kind: instance property of Request
Properties
Name | Type | Description |
---|---|---|
params | object | plugin configuration |
Array.<Attachment>
request.attachments : Kind: instance property of Request
number
| null
request.timestamp : timestamp
Kind: instance property of Request
string
request.senderId : senderId sender.id from the event
Kind: instance property of Request
string
request.recipientId : recipientId recipient.id from the event
Kind: instance property of Request
string
request.pageId : pageId page identifier from the event
Kind: instance property of Request
S
request.state : current state of the conversation
Kind: instance property of Request
Array.<string>
request.features : features supported messaging features
Kind: instance property of Request
Array.<string>
request.subscribtions : state list of subscribed tags
Kind: instance property of Request
Array.<Entity>
request.entities : entities list of entities
Kind: instance property of Request
Array.<Intent>
request.intents : intents list of resolved intents
Kind: instance property of Request
OrchestratorClientOptions
request._orchestratorClientOptions : Kind: instance property of Request
C
request.configuration : Kind: instance property of Request
object
request.event : The original messaging event
Kind: instance property of Request
enum
request.AI_SETSTATE : Kind: instance enum of Request
Properties
Name | Type | Default |
---|---|---|
ONLY | AiSetStateOption | 1 |
INCLUDE | AiSetStateOption | 0 |
EXCLUDE | AiSetStateOption | -1 |
EXCLUDE_WITH_SET_ENTITIES | AiSetStateOption | -2 |
EXCLUDE_WITHOUT_SET_ENTITIES | AiSetStateOption | -3 |
boolean
request.supportsFeature(feature) ⇒ Returns true if a channel supports specified feature
Kind: instance method of Request
Param | Type |
---|---|
feature | string |
boolean
request.isStandby() ⇒ Returns true, if the incoming event is standby
Kind: instance method of Request
Array.<IntentAction>
request.aiActions([local]) ⇒ Get all matched actions from NLP intents
Kind: instance method of Request
Param | Type | Default |
---|---|---|
[local] | boolean | false |
Array.<QuickReplyDisambiguation>
request.aiActionsForQuickReplies([limit], [aiActions], [overrideAction]) ⇒ Covert all matched actions for disambiguation purposes
Kind: instance method of Request
Param | Type | Default |
---|---|---|
[limit] | number | 5 |
[aiActions] | Array.<IntentAction> |
|
[overrideAction] | string | null |
boolean
request.hasAiActionsForDisambiguation(minimum, [local]) ⇒ Returns true, if there is an action for disambiguation
Kind: instance method of Request
Param | Type | Default |
---|---|---|
minimum | number | 1 |
[local] | boolean | false |
null
| string
| Intent
request.intent(getDataOrScore) ⇒ Returns intent, when using AI
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
getDataOrScore | boolean | number | false | score limit or true for getting intent data |
number
| string
| null
request.entity(name, [sequence]) ⇒ Get matched entity value
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
name | string | name of requested entity | |
[sequence] | number | 0 | when there are more then one entity |
boolean
request.isAttachment() ⇒ Checks, when message contains an attachment (file, image or location)
Kind: instance method of Request
request.isSetContext(varsToCheck)
Orchestrator: check, if the request updates only $context variables
- when no variables to check provided,
returns false when
set_context
is bundled within another conversational event
Kind: instance method of Request
Param | Type | Description |
---|---|---|
varsToCheck | Array.<string> | list of variables to check |
object
request.getSetContext([includeContextSync]) ⇒ Orchestrator: get current thread context update
Kind: instance method of Request
Returns: object
- - with §
prefixed keys
Param | Type | Default |
---|---|---|
[includeContextSync] | boolean | false |
boolean
request.isImage([attachmentIndex], [includingStickers]) ⇒ Checks, when the attachment is an image, but not a sticker
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[attachmentIndex] | number | 0 | use, when user sends more then one attachment |
[includingStickers] | boolean | false | return true, when the image is also a sticker |
boolean
request.isFile([attachmentIndex]) ⇒ Checks, when the attachment is a file
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[attachmentIndex] | number | 0 | use, when user sends more then one attachment |
boolean
request.hasLocation() ⇒ Checks for location in attachments
Kind: instance method of Request
null
| Object
request.getLocation() ⇒ 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');}});
object
| null
request.attachment([attachmentIndex]) ⇒ Returns whole attachment or null
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[attachmentIndex] | number | 0 | use, when user sends more then one attachment |
string
| null
request.attachmentUrl([attachmentIndex]) ⇒ Returns attachment URL
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[attachmentIndex] | number | 0 | use, when user sends more then one attachment |
boolean
request.isMessage() ⇒ Returns true, when the request is text message, quick reply or attachment
Kind: instance method of Request
boolean
request.isQuickReply() ⇒ Check, that message is a quick reply
Kind: instance method of Request
boolean
request.isText() ⇒ Check, that message is PURE text
Kind: instance method of Request
boolean
request.isSticker([includeToTextStickers]) ⇒ Returns true, when the attachment is a sticker
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[includeToTextStickers] | boolean | false | including strickers transformed into a text |
string
request.text([tokenized]) ⇒ Returns text of the message
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[tokenized] | boolean | false | when true, message is normalized to lowercase with - |
Example
console.log(req.text(true)) // "can-you-help-me"
Array.<TextAlternative>
request.textAlternatives() ⇒ Returns all text message alternatives including it's score
Kind: instance method of Request
Action
| null
request.expected() ⇒ 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
Param | Type | Default | Description |
---|---|---|---|
[justOnce] | boolean | false | - don't return already retained items |
Example
bot.use('my-route', (req, res) => {res.setState(req.expectedKeywords());});
object
request.expectedContext([justOnce], [includeKeywords]) ⇒ Returns current turn-around context (expected and expected keywords)
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[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());});
null
| string
| object
request.quickReply([getData]) ⇒ Returns action or data of quick reply
When getData
is true
, object will be returned. Otherwise string or null.
Kind: instance method of Request
Param | Type | Default |
---|---|---|
[getData] | boolean | false |
Example
typeof res.quickReply() === 'string' || res.quickReply() === null;typeof res.quickReply(true) === 'object';
boolean
request.isPostBack() ⇒ Returns true, if request is the postback
Kind: instance method of Request
boolean
request.isReferral() ⇒ Returns true, if request is the referral
Kind: instance method of Request
boolean
request.isOptin() ⇒ Returns true, if request is the optin
Kind: instance method of Request
Action
| null
| undefined
request.setAction(action, [data]) ⇒ Sets the action and returns previous action
Kind: instance method of Request
Returns: Action
| null
| undefined
- - previous action
Param | Type |
---|---|
action | string | Action | null |
[data] | object |
null
| string
request.action([getData]) ⇒ Returns action of the postback or quickreply
the order, where from the action is resolved
- referral
- postback
- optin
- quick reply
- expected keywords & intents
- expected action in state
- global or local AI intent action
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[getData] | boolean | false | deprecated |
Example
typeof res.action() === 'string' || res.action() === null;typeof res.actionData() === 'object';
object
request.actionData() ⇒ Returns action data of postback or quick reply
Kind: instance method of Request
object
request.getSetState(keysFromAi) ⇒ Gets incomming setState action variable
Kind: instance method of Request
Param | Type |
---|---|
keysFromAi | AiSetStateOption |
Example
res.setState(req.getSetState());
boolean
request.isConfidentInput() ⇒ 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
string
| null
request.actionByAi() ⇒ Returs action string, if there is an action detected by NLP
use rather designer's bounce feature instead of this pattern
Kind: instance method of Request
Example
const { Router } = require('wingbot');const bot = new Router();bot.use('question', (req, res) => {res.text('tell me your email').expected('email');});bot.use('email', async (req, res, postBack) => {if (req.actionByAi()) {await postBack(req.actionByAi(), {}, true);return;}res.text('thank you for your email');res.setState({ email: req.text() });});
IntentAction
| null
request.aiActionsWinner() ⇒ Returns full detected AI action
Kind: instance method of Request
null
| string
| object
request.postBack([getData]) ⇒ Returns action or data of postback
When getData
is true
, object will be returned. Otherwise string or null.
Kind: instance method of Request
Param | Type | Default |
---|---|---|
[getData] | boolean | false |
Example
typeof res.postBack() === 'string' || res.postBack() === null;typeof res.postBack(true) === 'object';
Array.<string>
request.expectedEntities() ⇒ Kind: instance method of Request
string
FEATURE_VOICE : channel supports voice messages
Kind: global constant
string
FEATURE_SSML : channel supports SSML voice messages
Kind: global constant
string
FEATURE_PHRASES : channel supports expected phrases messages
Kind: global constant
string
FEATURE_TEXT : channel supports text communication
Kind: global constant
string
FEATURE_TRACKING : channel supports tracking protocol
Kind: global constant
string
FEATURE_VOICE : channel supports voice messages
Kind: global constant
string
FEATURE_SSML : channel supports SSML voice messages
Kind: global constant
string
FEATURE_PHRASES : channel supports expected phrases messages
Kind: global constant
string
FEATURE_TEXT : channel supports text communication
Kind: global constant
string
FEATURE_TRACKING : channel supports tracking protocol
Kind: global constant
object
Entity : Kind: global typedef
Properties
Name | Type |
---|---|
entity | string |
value | string |
score | number |
[alternatives] | Array.<Entity> |
object
Intent : Kind: global typedef
Properties
Name | Type |
---|---|
intent | string |
score | number |
[entities] | Array.<Entity> |
object
Action : Kind: global typedef
Properties
Name | Type |
---|---|
action | string |
data | object |
[setState] | object | null |
object
IntentAction : Kind: global typedef
Properties
Name | Type |
---|---|
action | string |
intent | Intent |
sort | number |
local | boolean |
aboveConfidence | boolean |
[data] | object |
[match] | string | Array.<string> |
[setState] | object |
[winner] | boolean |
[title] | string | function |
[hasAiTitle] | boolean |
meta | object |
[meta.targetAppId] | string |
[meta.targetAction] | string | null |
[meta.resolverTag] | string |
object
QuickReply : Kind: global typedef
Properties
Name | Type |
---|---|
action | string |
title | * |
object
QuickReplyDisambiguation : Kind: global typedef
Properties
Name | Type |
---|---|
action | string |
title | string |
data | object |
templateData | object |
object
RequestOrchestratorOptions : Kind: global typedef
Properties
Name | Type |
---|---|
[apiUrl] | string |
[secret] | Promise.<string> |
[fetch] | function |
[appId] | string |
object
TextAlternative : Kind: global typedef
Properties
Name | Type |
---|---|
text | string |
score | number |
object
Attachment : Kind: global typedef
Properties
Name | Type |
---|---|
type | 'file' | 'audio' | 'video' | 'image' |
payload | object |
payload.url | string |
number
AiSetStateOption : Kind: global typedef