@aiteq/messenger-bot > ElementBuilder
Helps to create an Element.
↳ ElementBuilder
- addCallButton(title, phoneNumber)
- addExtensionButton(title, extension, [options])
- addLoginButton(url)
- addLogoutButton()
- addPostbackButton(title, id, [data])
- addShareButton(builder)
- addUrlButton(title, url, [options])
- setDefaultAction(url, [options])
- setExtensionDefaultAction(extension, [options])
- setImageUrl(imageUrl)
- setSubtitle(subtitle)
Creates an instance of ElementBuilder.
Parameters:
Param | Type | Description |
---|---|---|
title | string |
title of the Element |
Returns: ElementBuilder
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
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
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
Creates and adds a Logout Button.
Inherited from ButtonHoldingBuilder.
Returns: this
- for chaining
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
Creates and adds a Share Button.
Inherited from ButtonHoldingBuilder.
Parameters:
Param | Type | Description |
---|---|---|
builder | GenericTemplateMessageBuilder | a generic template message builder |
Returns: this
- for chaining
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
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
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
Sets Element's image.
Parameters:
Param | Type | Description |
---|---|---|
imageUrl | string |
URL of the image of the Element |
Returns: this
- for chaining
Sets a text for Element's subtitle.
Parameters:
Param | Type | Description |
---|---|---|
subtitle | string |
subtitle of the Element |
Returns: this
- for chaining