Skip to content

Latest commit

 

History

History
410 lines (274 loc) · 11.8 KB

botutils.md

File metadata and controls

410 lines (274 loc) · 11.8 KB

@aiteq/messenger-bot > BotUtils

Class: BotUtils

Provides an interface to non-interactive services of Messenger Platform API through a set of convenient methods.

Index

Constructors

Methods


Constructors

new BotUtils(config)

Creates an instance of BotUtils.

Parameters:

Param Type Description
accessToken string bot configuration object (only the accessToken property is required)

Returns: BotUtils


Methods

setGreeting(text, [locale])

Sets the Greeting for the Page. If it is already set for the locale, it will be changed.

Parameters:

Param Type Default value Description
text string a greeting text
locale string "default" a locale of the greeting (supported locales)

Returns: Promise<MessengerProfile.Response>


blacklistAudienceCountries(countries)

Adds countries to Target Audience blacklist.

Parameters:

Param Type Description
countries Array<string> a list of ISO 3166 Alpha-2 codes of countries to be blacklisted

Returns: Promise<MessengerProfile.Response>


closeTargetAudience()

Close Target Audience to all.

Returns: Promise<MessengerProfile.Response>


deleteAccountLinkingUrl()

Removes current setting of Account Linking URL.

Returns: Promise.<MessengerProfile.Response`>


deleteChatExtensionHomeUrl()

Removes current setting of Chat Extension home URL.

Returns: Promise<MessengerProfile.Response>


`deleteDomainWhitelist()!

Removes all domains from whitelist.

Returns: Promise<MessengerProfile.Response>


deleteGetStartedButton()

Disables the Get Started button on the Page.

Note: Get Started button can't be removed when a Persistent Menu is set while Persistent Menu can't be used without Get Started button.

Returns: Promise<MessengerProfile.Response>


deleteGreeting()

Removes the current Greeting.

Returns: Promise<MessengerProfile.Response>


deletePersistentMenu()

Removes the current Persistent Menu.

Returns: Promise<MessengerProfile.Response>


deleteTargetAudience()

Removes all countris from both whitelist and blacklist.

Returns: Promise<MessengerProfile.Response>


generateMessengerCode(fileName, [size, [ref]])

Generates and saves a new Messenger Code as PNG image.

Parameters:

Param Type Description
fileName string a path and name of the file to be saved
size number a size of the image (ragnge: 100 - 2000, default: 1000)
ref string optional data to be sent when the user scans the code

Returns: Promise<MessengerProfile.Response>


`getAccountLinkingUrl()'

Returns current Account Linking URL.

Returns: Promise<string> - current Account Linking URL


getChatExtensionHomeUrl()

Returns Chat Extension home URL.

Returns: Promise<string> - current Chat Extension home URL


getDomainWhitelist()

Returns current list of whitelisted domains.

Returns: Promise<any> - a list of whitelisted domains


getGetStartedButton()

Reads the current Get Started button setting.

Returns: Promise<MessengerProfile.GetStartedButton> - an object with Get Started button setting


getGreeting()

Reads the current Greeting.

Returns: Promise<MessengerProfile.Greeting[]> - an array of greetings


getPersistentMenu()

Returns the current Persistent Menu.

Returns: Promise<any> - an object with Persistent Menu definition


getTargetAudience()

Returns current Target Audience setting.

Returns: Promise<any> - an object with current Target Audience settings


openTargetAudience()

Open Target Audience to all.

Returns: Promise<any>


sendAudio(recipientId, url, reusable)

Sends a message with audio attachment.

Parameters:

Param Type Description
recipientId string ID of the recipient
url string URL of the audio file
reusable boolean controls whether the attachment is to be reused

Returns: Promise<Send.Response>

Note: The attachment reusing is managed automatically by the package. So, when you don't intend to reuse the attachment outside the package, you can forget the returned value.


sendFile(recipientId, url, reusable)

Sends a message with file attachment.

Parameters:

Param Type Description
recipientId string ID of the recipient
url string URL of the file
reusable boolean controls whether the attachment is to be reused

Returns: Promise<Send.Response>

Note: The attachment reusing is managed automatically by the package. So, when you don't intend to reuse the attachment outside the package, you can forget the returned value.


sendImage(recipientId, url, reusable)

Sends a message with image attachment.

Parameters:

Param Type Description
recipientId string ID of the recipient
url string URL of the image
reusable boolean controls whether the attachment is to be reused

Returns: Promise<Send.Response>

Note: The attachment reusing is managed automatically by the package. So, when you don't intend to reuse the attachment outside the package, you can forget the returned value.


sendText(recipientId, text)

Sends a plain text message.

Parameters:

Param Type Description
recipientId string ID of the recipient
text string a text to be send

Returns: Promise<Send.Response>


sendVideo(recipientId, url, reusable)

Sends a message with video attachment.

Parameters:

Param Type Description
recipientId string ID of the recipient
url string URL of the video file
reusable boolean controls whether the attachment is to be reused

Returns: Promise<Send.Response>

Note: The attachment reusing is managed automatically by the package. So, when you don't intend to reuse the attachment outside the package, you can forget the returned value.


setAccountLinkingUrl(url)

Sets a new Account Linking URL.

Parameters:

Param Type Description
url string new Account Linking URL

Returns: Promise<MessengerProfile.Response>


setChatExtensionHomeUrl(url, [inTest, [shareButton]])

Sets a new Chat Extension home URL. If the URL is not whitelisted it will be done first.

Parameters:

Param Type Default value Description
url string new Chat Extension home URL
inTest boolean false controls whether the Chat Extension is in test mode
shareButton boolean true controls whether the share button in the webview is enabled

Returns: Promise<MessengerProfile.Response>


setGetStartedButton([data])

Sets Get Started button for the Page.

Parameters:

Param Type Description
data any optional data to be sent when the user clicks on the button

Returns: Promise<MessengerProfile.Response>


setPersistentMenu(menuDef)

Sets Persistent Menu for the Page.

Parameters:

Param Type Description
menuDef PersistentMenuDefArray<PersistentMenuDef> ⎮ PersistentMenuBuilder definition of Persistent Menu

Returns: Promise<MessengerProfile.Response>


whitelistAudienceCountries(countries)

Adds countries to Target Audience whitelist.

Parameters:

Param Type Description
countries Array<string> list of ISO 3166 Alpha-2 codes of countries to be whitelisted

Returns: Promise<MessengerProfile.Response>


whitelistDomains(domains)

Adds domains to the whitelist.

Parameters:

Param Type Description
domains string Array<string>

Returns: Promise<void>