Components API object

Hierarchy

Implements

Constructors

Properties

Methods

Constructors

  • 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

    • sub_type: "url" | "quick_reply"

      The type of button to create.

    • Rest ...parameters: AtLeastOne<string>

      Parameter for each button. The index of each parameter is defined by the order they are sent to the constructor.

    Returns ButtonComponent

    Remarks

    Empty strings are not allowed in the API. However, rather than being ignored or throwing an error, the constructor will use them as dummies for fake variables.

    You might want to know why. So do I. It's a really dumb catch to fix an issue on the API side. If you have a template with 2 buttons, the first one a phone number (which can't take variables), and an url button (which can have variables), the API will throw an error because the first button can't take variables, even though it DOESN'T need a variable.

    For such cases, the expected code would be:

    const template = new Template(
    "name",
    "en_US",
    new ButtonComponent(
    "url",
    "", // As the first button is a phone, skip assigning it a variable
    "?user=123"
    )
    );

    Throws

    If parameters is over 3 elements

Properties

parameters: (null | ButtonParameter)[]

The ButtonParameters to be used in the build function

sub_type: "url" | "quick_reply"

The subtype of the component

type: "button"

The type of the component

Methods

Generated using TypeDoc