ButtonTemplate: Class
The ButtonTemplate
class is used to create a button template message. It has a text
property and a buttons
property. The text
property is the text of the button template message. The buttons
property is an array of
CallButton
, PostbackButton
, or UrlButton
objects.
Usage
const { ButtonTemplate } = require('chat-bridge')
Constructor
To create a new ButtonTemplate
object, use the following code:
const buttonTemplate = new ButtonTemplate('Button Template Text')
Methods
addButtons
addButtons(buttons: Array<CallButton | PostbackButton | UrlButton>): ButtonTemplate
- Adds buttons to theButtonTemplate
object. Returns theButtonTemplate
object.
const buttonTemplate = new ButtonTemplate('Hello, World!').addButtons([
new CallButton('Call Button', '+6281234567890'),
new PostbackButton('Postback Button', 'postback'),
new UrlButton('Url Button', 'https://chat-bridge.pages.dev/'),
])
You can learn more about the CallButton
, PostbackButton
, and UrlButton
classes in the
Button API.