Request
Kind: global class
- Request
- new Request()
- .timestamp
- .senderId
- .recipientId
- .pageId
- .state
- .isAttachment() ⇒
boolean
- .isImage([attachmentIndex]) ⇒
boolean
- .isFile([attachmentIndex]) ⇒
boolean
- .attachment([attachmentIndex]) ⇒
object
|null
- .attachmentUrl([attachmentIndex]) ⇒
string
|null
- .isMessage() ⇒
boolean
- .isQuickReply() ⇒
boolean
- .isText() ⇒
boolean
- .text([tokenized]) ⇒
string
- .expected() ⇒
string
|null
- .quickReply([getData]) ⇒
null
|string
|object
- .isPostBack() ⇒
boolean
- .isReferral() ⇒
boolean
- .isPassThread() ⇒
boolean
- .isOptin() ⇒
boolean
- .action([getData]) ⇒
null
|string
|object
- .postBack([getData]) ⇒
null
|string
|object
new Request()
Instance of {Request} class is passed as first parameter of handler (req)
request.timestamp
Kind: instance property of Request
Properties
Type | |
---|---|
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.isAttachment() ⇒ boolean
Checks, when message contains an attachment (file, image or location)
Kind: instance method of Request
request.isImage([attachmentIndex]) ⇒ boolean
Checks, when the attachment is an image
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[attachmentIndex] | number |
0 |
use, when user sends more then one attachment |
request.isFile([attachmentIndex]) ⇒ boolean
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 |
request.attachment([attachmentIndex]) ⇒ object
| null
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 |
request.attachmentUrl([attachmentIndex]) ⇒ string
| null
Returns attachment URL
Kind: instance method of Request
Param | Type | Default | Description |
---|---|---|---|
[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.text([tokenized]) ⇒ string
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"
request.expected() ⇒ string
| null
Returns the request expected handler in case have been set last response
Kind: instance method of Request
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
Param | Type | Default |
---|---|---|
[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.isPassThread() ⇒ boolean
Returns true, if request pass thread control
Kind: instance method of Request
request.isOptin() ⇒ boolean
Returns true, if request is the optin
Kind: instance method of Request
request.action([getData]) ⇒ null
| string
| object
Returns action of the postback or quickreply
When getData
is true
, object will be returned. Otherwise string or null.
- the postback is checked
- the referral is checked
- the quick reply is checked
- expected keywords are checked
- expected state is checked
Kind: instance method of Request
Param | Type | Default |
---|---|---|
[getData] | boolean |
false |
Example
typeof res.action() === 'string' || res.action() === null;
typeof res.action(true) === 'object';
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
Param | Type | Default |
---|---|---|
[getData] | boolean |
false |
Example
typeof res.postBack() === 'string' || res.postBack() === null;
typeof res.postBack(true) === 'object';