Class: Skill

Skill(config)

new Skill(config)

Class to implement skill.
Parameters:
Name Type Description
config Object Object which contains skill specific configurations.
Properties:
Name Type Default Description
required_parameter Skill#skill_parameter_container Object to list required parameters for the skill.
optional_parameter Skill#skill_parameter_container Object to list optional parameters for the skill.
clear_context_on_finish boolean false Flag to flush context information on skill finishes. Set true to flush.
Source:

Methods

(async) begin(bot, event, context)

Function which is triggerd at first.
Parameters:
Name Type Description
bot Bot Toolkit which can be used to access Messenger API, queuing messeage, collecting arbitrary parameter and son on.
event Object Event object which triggers this flow.
context context Context information.
Source:

(async) finish(bot, event, context)

Function which is triggerd when all the required parameters are collected.
Parameters:
Name Type Description
bot Bot Toolkit which can be used to access Messenger API, queuing messeage, collecting arbitrary parameter and son on.
event Object Event object which triggers this flow.
context context Context information.
Source:

Type Definitions

(async) condition(bot, event, context) → {Boolean}

Function to check if the parameter should be collected.
Parameters:
Name Type Description
bot Bot Toolkit which can be used to access Messenger API, queuing messeage, collecting arbitrary parameter and son on.
event Object Event object which triggers this flow.
context context Context information.
Source:
Returns:
- True to collect the parameter. False to skip.
Type
Boolean

(async) message(bot, event, context) → {Object}

Function to generate message to confirm the value of teh parameter.
Parameters:
Name Type Description
bot Bot Toolkit which can be used to access Messenger API, queuing messeage, collecting arbitrary parameter and son on.
event Object Event object which triggers this flow.
context context Context information.
Source:
Returns:
You have to return message object.
Type
Object

(async) parser_function(value, bot, event, context)

Function which is applied to the message from user to validate the value. If validation succeeds, return any type of value you like to set as confirmed parameter. If validation fails, throw error without changing error name.
Parameters:
Name Type Description
value * Data to parse. In case of text message, its text will be set in string. In case of postback event, data payload will be set in string. In other cases, message object will be set as it is.
bot Bot Toolkit which can be used to access Messenger API, queuing messeage, collecting arbitrary parameter and son on.
event Object Event object which triggers this flow.
context context Context information.
Source:

parser_object

The object of built-in parser configuratin.
Type:
  • Object
Properties:
Name Type Description
type String Type of built-in parser. Supported value is dialogflow, email, list, number and string.
policy Object Policy configuration depending on the each parser implementation.
Source:

(async) reaction(error, value, bot, event, context)

Function which is triggered when parser finshed parsing. You can implement custom behavior on collecting parameter including async action.
Parameters:
Name Type Description
error Boolean Flag which indicates if parser accepted the value. When accepted, true is set.
value * Parsed value.
bot Bot Toolkit which can be used to access Messenger API, queuing messeage, collecting arbitrary parameter and son on.
event Object Event object which triggers this flow.
context context Context information.
Source:

skill_parameter

Object which defines how this parameter should be collected, parsed, and reacted.
Type:
  • Object
Properties:
Name Type Attributes Default Description
message Object | Skill#message <optional>
Message Object to ask for users the value of this parameter. As for message format, you can use either LINE or Facebook Messenger. In addition, you can also set function to generate message dynamically.
list Boolean | Object <optional>
false Flag to make this parameter list. Set true to make the parameter list in newest first order. You can also specify object to control behavior of list.
Properties
Name Type Attributes Default Description
order String <optional>
new Order of the list. "new" for newest first. "old" for oldest first.
condition Skill#condition <optional>
Function to check if this parameter should be collected. Return true to collect and false to skip.
parser Skill#parser_function | String | Skill#parser_object <optional>
Function to parse the message from user. Function, string and object can be provided. In case of function, it is used as it is. In case of string, you can specify the type of built-in parser. In case of object, you can specify parser_object.
reaction Skill#reaction <optional>
Function to react to the message from user. Reaction runs right after paser returns.
sub_skill Array.<String> <optional>
List of sub skills. If user intends these skills in the middle of the conversation, we switch context to new intent and get back once finished.
sub_parameter Skill#skill_parameter_container <optional>
You can set nested parameter container. When all the parameters defined under sub_parameter are set, aggregated object will be set to parent parameter.
Source:

skill_parameter_container

Object which contains one skill parameter.
Type:
  • Object
Properties:
Name Type Description
* Skill#skill_parameter Skill parameter object.
Source: