@aiteq/messenger-bot > BotUtils
Provides an interface to non-interactive services of Messenger Platform API through a set of convenient methods.
- blacklistAudienceCountries(countries)
- closeTargetAudience()
- deleteAccountLinkingUrl()
- deleteChatExtensionHomeUrl()
- deleteDomainWhitelist()
- deleteGetStartedButton()
- deleteGreeting()
- deletePersistentMenu()
- deleteTargetAudience()
- generateMessengerCode(fileName, [size, [ref]])
- getAccountLinkingUrl()
- getChatExtensionHomeUrl()
- getDomainWhitelist()
- getGetStartedButton()
- getGreeting()
- getPersistentMenu()
- getTargetAudience()
- openTargetAudience()
- sendAudio(recipientId, url, reusable)
- sendFile(recipientId, url, reusable)
- sendImage(recipientId, url, reusable)
- sendText(recipientId, text)
- sendVideo(recipientId, url, reusable)
- setAccountLinkingUrl(url)
- setChatExtensionHomeUrl(url, [inTest, [shareButton]])
- setGetStartedButton([data])
- setGreeting(text, [locale])
- setPersistentMenu(menuDef)
- whitelistAudienceCountries(countries)
- whitelistDomains(domains)
Creates an instance of BotUtils.
Parameters:
Param | Type | Description |
---|---|---|
accessToken | string |
bot configuration object (only the accessToken property is required) |
Returns: BotUtils
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
>
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
>
Close Target Audience to all.
Returns: Promise
<MessengerProfile.Response
>
Removes current setting of Account Linking URL.
Returns: Promise.<
MessengerProfile.Response`>
Removes current setting of Chat Extension home URL.
Returns: Promise
<MessengerProfile.Response
>
Removes all domains from whitelist.
Returns: Promise
<MessengerProfile.Response
>
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
>
Removes the current Greeting.
Returns: Promise
<MessengerProfile.Response
>
Removes the current Persistent Menu.
Returns: Promise
<MessengerProfile.Response
>
Removes all countris from both whitelist and blacklist.
Returns: Promise
<MessengerProfile.Response
>
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
>
Returns current Account Linking URL.
Returns: Promise
<string
> - current Account Linking URL
Returns Chat Extension home URL.
Returns: Promise
<string
> - current Chat Extension home URL
Returns current list of whitelisted domains.
Returns: Promise
<any
> - a list of whitelisted domains
Reads the current Get Started button setting.
Returns: Promise
<MessengerProfile.GetStartedButton
> - an object with Get Started button setting
Reads the current Greeting.
Returns: Promise
<MessengerProfile.Greeting[]
> - an array of greetings
Returns the current Persistent Menu.
Returns: Promise
<any
> - an object with Persistent Menu definition
Returns current Target Audience setting.
Returns: Promise
<any
> - an object with current Target Audience settings
Open Target Audience to all.
Returns: Promise
<any
>
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.
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.
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.
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
>
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.
Sets a new Account Linking URL.
Parameters:
Param | Type | Description |
---|---|---|
url | string |
new Account Linking URL |
Returns: Promise
<MessengerProfile.Response
>
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
>
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
>
Sets Persistent Menu for the Page.
Parameters:
Param | Type | Description |
---|---|---|
menuDef | PersistentMenuDef ⎮ Array <PersistentMenuDef> ⎮ PersistentMenuBuilder |
definition of Persistent Menu |
Returns: Promise
<MessengerProfile.Response
>
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
>
Adds domains to the whitelist.
Parameters:
Param | Type | Description |
---|---|---|
domains | string |
Array <string > |
Returns: Promise
<void
>