Constructor
new Bot(options, slib, event, context)
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | |
slib |
Object | |
event |
Object | |
context |
Object |
Properties:
Name | Type | Description |
---|---|---|
type |
String | Type of messenger. The value can be "line","facebook" and "google". |
language |
String | ISO-639-1 based language code which is the mother language of this chatbot. |
builtin_parser |
Object | Instance of builtin parser. You can use builtin parser like follows. await bot.builtin_parser.PARSER_NAME(value, policy). |
- Source:
Methods
add_parameter(param_name, param_value, is_changeopt)
Add parameter to context as confirmed.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
param_name |
String | |||
param_value |
* | |||
is_change |
Boolean |
<optional> |
false |
- Source:
(async) apply_parameter(param_name, param_value, parseopt, reactopt)
Manually apply value to the parameter. We can select if parser and reaction would be conducted.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
param_name |
String | Name of the parameter to apply. | ||
param_value |
* | Value to apply. | ||
parse |
Boolean |
<optional> |
false | Whether to run parser. |
react |
Boolean |
<optional> |
true | Whether to run reaction. |
- Source:
change_message(param_name, message)
Change the message to collect specified parameter.
Parameters:
Name | Type | Description |
---|---|---|
param_name |
String | Name of the parameter to collect. |
message |
MessageObject | The message object. |
- Source:
change_message_to_confirm(param_name, message)
Wrapper of change_message for backward compatibility.
Parameters:
Name | Type | Description |
---|---|---|
param_name |
String | Name of the parameter to collect. |
message |
MessageObject | The message object. |
- Source:
check_parameter_type(param_name) → {String}
Check parameter type.
Parameters:
Name | Type | Description |
---|---|---|
param_name |
String | Parameter name. |
- Source:
Returns:
"required_parameter" | "optional_parameter" | "dynamic_parameter" | "sub_parameter" | "not_applicable"
- Type
- String
collect(arg, optionsopt)
Make the specified skill paramter being collected next.
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
arg |
String | Skill#skill_parameter_container | Name of the skill parameter or skill_parameter_container object to collect. | |||||||||||
options |
Object |
<optional> |
Option object.
Properties
|
- Source:
compile_message(message, format) → {Promise.<MessageObject>}
Compile message format to the specified format.
Parameters:
Name | Type | Description |
---|---|---|
message |
MessageObject | Message object to compile. |
format |
String | Target format to compile. It can be "line" or "facebook". |
- Source:
Returns:
- Compiled message object.
- Type
- Promise.<MessageObject>
exit()
Stop processing all remaining actions and keep context except for confirming.
- Source:
extract_message(event) → {MessageObject}
Extract message of the event.
Parameters:
Name | Type | Description |
---|---|---|
event |
EventObject | Event to extract message. |
- Source:
Returns:
- Extracted message.
- Type
- MessageObject
extract_message_text(event) → {String}
Extract message text.
Parameters:
Name | Type | Description |
---|---|---|
event |
EventObject | Event to extract message text. |
- Source:
Returns:
- Extracted message text.
- Type
- String
extract_sender_id(event) → {String}
Extract sender's user id.
Parameters:
Name | Type | Description |
---|---|---|
event |
EventObject | Event to extract message text. |
- Source:
Returns:
- Extracted sender's user id.
- Type
- String
extract_session_id(event) → {String}
Extract session id.
Parameters:
Name | Type | Description |
---|---|---|
event |
EventObject | Event to extract message text. |
- Source:
Returns:
- Extracted sender's user id.
- Type
- String
get_parameter(param_name) → {Object}
Get parameter object by parameter name.
Parameters:
Name | Type | Description |
---|---|---|
param_name |
String |
- Source:
Returns:
Parameter object.
- Type
- Object
identify_event_type(event) → {String}
Identify the event type.
Parameters:
Name | Type | Description |
---|---|---|
event |
EventObject | Event to identify event type. |
- Source:
Returns:
- Event type. In case of LINE, it can be "message", "follow", "unfollow", "join", "leave", "postback", "beacon". In case of Facebook, it can be "echo", "message", "delivery", "read", "postback", "optin", "referral", "account_linking".
- Type
- String
identify_message_type(message) → {String}
Identify the message type.
Parameters:
Name | Type | Description |
---|---|---|
message |
MessageObject | Message Object to identify message type. |
- Source:
Returns:
- Message type. In case of LINE, it can be "text", "image", "audio", "video", "file", "location", "sticker", "imagemap", "buttons_template, "confirm_template" or "carousel_template". In case of Facebook, it can be "text", "image", "audio", "video", "file", "button_template", "generic_template", "list_template", "open_graph_template", "receipt_template", "airline_boardingpass_template", "airline_checkin_template", "airline_itinerary_template", "airline_update_template".
- Type
- String
init()
Stop processing all remaining actions and clear context completely.
- Source:
(async) multicast(recipient_ids, messages, language) → {Object}
Send(Push) messages to multiple users.
Parameters:
Name | Type | Description |
---|---|---|
recipient_ids |
Array.<String> | Array of recipent user id. |
messages |
MessageObject | Array.<MessageObject> | Message object[s] to send. |
language |
String | ISO-639-1 based language code to translate to. |
- Source:
Returns:
- Response from Messenger API.
- Type
- Object
(async) parse_parameter(param_name, param_value, strictopt) → {*}
Run parser defined in skill.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
param_name |
String | Parameter name. | ||
param_value |
* | Value to validate. | ||
strict |
Boolean |
<optional> |
false | If true, reject if parser does not exist. This option is for imternal use. |
- Source:
Returns:
- Type
- *
pause()
Stop processing all remaining actions and keep context.
- Source:
queue(messages)
Queue messages. The messages will be sent out when reply(MESSAGES) function is called.
Parameters:
Name | Type | Description |
---|---|---|
messages |
MessageObject | Array.<MessageObject> | Message object[s] to queue. |
- Source:
(async) react(error, param_name, param_value)
Run reaction defined in skill.
Parameters:
Name | Type | Description |
---|---|---|
error |
Error | |
param_name |
String | |
param_value |
* |
- Source:
(async) reply(messages) → {Object}
Reply message to sender. This function can be called just once in a flow. To send multiple messages, give multiple messages to this function or use queue(MESSAGES) function instead.
Parameters:
Name | Type | Description |
---|---|---|
messages |
MessageObject | Array.<MessageObject> | Message object[s] to reply. |
- Source:
Returns:
- Response from Messenger API.
- Type
- Object
(async) reply_to_collect(messages) → {Object}
Reply messages to sender to collect parameter
Parameters:
Name | Type | Description |
---|---|---|
messages |
Array.<MessageObject> | The array of message objects. |
- Source:
Returns:
- Response from Messenger API.
- Type
- Object
(async) send(recipient_id, messages, language) → {Object}
Send(Push) message to specified user.
Parameters:
Name | Type | Description |
---|---|---|
recipient_id |
String | Recipient user id. |
messages |
MessageObject | Array.<MessageObject> | Messages object[s] to send. |
language |
String | ISO-639-1 based language code to translate to. |
- Source:
Returns:
- Response from Messenger API.
- Type
- Object
switch_skill(intent)
Switch skill using provided intent. If this method is called in the middle of flow, rest of the process is skipped.
Parameters:
Name | Type | Description |
---|---|---|
intent |
intent |
- Source:
(async) t(key, options) → {String}
Alias to this.translator.t
Parameters:
Name | Type | Description |
---|---|---|
key |
String | |
options |
Object |
- Source:
Returns:
Translation label.
- Type
- String