Skip to content

Latest commit

 

History

History
257 lines (171 loc) · 8.75 KB

elementbuilder.md

File metadata and controls

257 lines (171 loc) · 8.75 KB

@aiteq/messenger-bot > ElementBuilder

Class: ElementBuilder

Helps to create an Element.

Hierarchy

ButtonHoldingBuilder

↳ ElementBuilder

Index

Constructors

Methods


Constructors

new ElementBuilder(title)

Creates an instance of ElementBuilder.

Parameters:

Param Type Description
title string title of the Element

Returns: ElementBuilder


Methods

addCallButton(title, phoneNumber)

Creates and adds a Call Button.

Inherited from ButtonHoldingBuilder.

Parameters:

Param Type Description
title string title of the button, max length is 20 characters
phoneNumber string phone number, format must have "+" prefix followed by the country code, area code and local number (e.g. +16505551234)

Returns: this - for chaining


addExtensionButton(title, extension, [options])

Creates and adds a URL Button linking a Chat Extension.

Inherited from ButtonHoldingBuilder.

Parameters:

Param Type Description
title string a title of the button, max length is 20 characters
extension ChatExtension a Chat Extension to be opened when the button is tapped
options object

options object can contain:

Property Type Description
webviewHeightRatio HeightRatio optional height of the Webview
webviewShareButton boolean set to false to disable sharing in the Webview (e.g. for sensitive info)
fallbackUrl string URL to use on clients that don't support Messenger Extensions

Returns: this - for chaining


addLoginButton(url)

Creates and adds a Login Button.

Inherited from ButtonHoldingBuilder.

Parameters:

Param Type Description
url string authentication callback URL (must use HTTPS protocol)

Returns: this - for chaining


addLogoutButton()

Creates and adds a Logout Button.

Inherited from ButtonHoldingBuilder.

Returns: this - for chaining


addPostbackButton(title, id, [data])

Creates and adds a Postback Button.

Inherited from ButtonHoldingBuilder.

Parameters:

Param Type Description
title string a title of the button, max length is 20 characters
id string an identification of the postback
data string optional data to be send with postback

Returns: this - for chaining


addShareButton(builder)

Creates and adds a Share Button.

Inherited from ButtonHoldingBuilder.

Parameters:

Param Type Description
builder GenericTemplateMessageBuilder a generic template message builder

Returns: this - for chaining


addUrlButton(title, url, [options])

Creates and adds a URL Button.

Inherited from ButtonHoldingBuilder.

Parameters:

Param Type Description
title string a title of the button, max length is 20 characters
url string a URL to be opened in a mobile browser when the button is tapped
options object

options object can contain:

Property Type Description
webviewHeightRatio HeightRatio optional height of the Webview
messengerExtensions boolean must be true if using Messenger Extensions
webviewShareButton boolean set to false to disable sharing in the Webview (e.g. for sensitive info)
fallbackUrl string URL to use on clients that don't support Messenger Extensions

Returns: this - for chaining


setDefaultAction(url, [options])

Set a Default Action for the Element.

Parameters:

Param Type Description
url string a URL to be opened
options object

options object can contain:

Property Type Description
webviewHeightRatio HeightRatio optional height of the Webview
messengerExtensions boolean must be true if using Messenger Extensions
webviewShareButton boolean set to false to disable sharing in the Webview (e.g. for sensitive info)
fallbackUrl string URL to use on clients that don't support Messenger Extensions

Returns: this - for chaining


setExtensionDefaultAction(extension, [options])

Set a Default Action for the Element linking a Chat Extension.

Parameters:

Param Type Description
extension ChatExtension a Chat Extension to be opened
options object

options object can contain:

Property Type Description
webviewHeightRatio HeightRatio optional height of the Webview
(https://developers.facebook.com/docs/messenger-platform/send-api-reference/webview)
webviewShareButton boolean set to false to disable sharing in the Webview (e.g. for sensitive info)
fallbackUrl string URL to use on clients that don't support Messenger Extensions

Returns: this - for chaining


setImageUrl(imageUrl)

Sets Element's image.

Parameters:

Param Type Description
imageUrl string URL of the image of the Element

Returns: this - for chaining


setSubtitle(subtitle)

Sets a text for Element's subtitle.

Parameters:

Param Type Description
subtitle string subtitle of the Element

Returns: this - for chaining