ButtonComponent

ButtonComponent

Components API object

Constructor

new ButtonComponent(sub_type, …parameters)

Source:
Properties:
Name Type Description
type String The type of the component
sub_type String The subtype of the component
parameters Array.<ButtonParameter> The ButtonParameters to be used in the build function
build function The function to build the component as a compatible API object
Builds a button component for a Template message. The index of the buttons is defined by the order in which you add them to the Template parameters.
Parameters:
Name Type Attributes Description
sub_type String Type of button to create. Can be either 'url' or 'quick_reply'.
parameters String <repeatable>
Parameter for each button. The index of each parameter is defined by the order they are sent to the constructor.
Throws:
  • If sub_type is not either 'url' or 'quick_reply'
    Type
    Error
  • If parameters is not provided
    Type
    Error
  • If parameters has over 3 elements
    Type
    Error

Methods

build() → {Array.<{type: String, sub_type: String, index: String, parameters: Array.<ButtonParameter>}>}

Source:
Generates the buttons components for a Template message. For internal use only.
Returns:
An array of API compatible buttons components
Type
Array.<{type: String, sub_type: String, index: String, parameters: Array.<ButtonParameter>}>