NotificationBot class
Provide utilities to send notification to varies targets (e.g., member, group, channel).
Constructors
Notification |
Constructor of the notification bot. |
Methods
build |
Create a TeamsBotInstallation instance with conversation reference. |
find |
Return all Channel where predicate is true, and empty array otherwise.
(Ensure the bot app is installed into the |
find |
Return all Member where predicate is true, and empty array otherwise. |
find |
Return the first Channel where predicate is true, and undefined otherwise.
(Ensure the bot app is installed into the |
find |
Return the first Member where predicate is true, and undefined otherwise. |
get |
Gets a pagined list of targets where the bot is installed. |
installations() | Get all targets where the bot is installed. |
validate |
Validate the installation by getting paged memebers. |
Constructor Details
NotificationBot(CloudAdapter, NotificationOptions_3)
Constructor of the notification bot.
new NotificationBot(adapter: CloudAdapter, options?: NotificationOptions_3)
Parameters
- adapter
-
CloudAdapter
The bound CloudAdapter
- options
- NotificationOptions
The initialize options
Remarks
To ensure accuracy, it's recommended to initialize before handling any message.
Method Details
buildTeamsBotInstallation(Partial<ConversationReference>)
Create a TeamsBotInstallation instance with conversation reference.
function buildTeamsBotInstallation(conversationReference: Partial<ConversationReference>): null | TeamsBotInstallation_2
Parameters
- conversationReference
-
Partial<ConversationReference>
The bound ConversationReference
.
Returns
null | TeamsBotInstallation
- The TeamsBotInstallation instance or null.
findAllChannels((channel: Channel_2, teamDetails: undefined | TeamDetails) => Promise<boolean>)
Return all Channel where predicate is true, and empty array otherwise.
(Ensure the bot app is installed into the General
channel, otherwise empty array will be returned.)
function findAllChannels(predicate: (channel: Channel_2, teamDetails: undefined | TeamDetails) => Promise<boolean>): Promise<Channel_2[]>
Parameters
- predicate
-
(channel: Channel_2, teamDetails: undefined | TeamDetails) => Promise<boolean>
Find calls predicate for each channel of the installation.
Returns
Promise<Channel[]>
An array of Channel where predicate is true, and empty array otherwise.
findAllMembers((member: Member_2) => Promise<boolean>, SearchScope_2)
Return all Member where predicate is true, and empty array otherwise.
function findAllMembers(predicate: (member: Member_2) => Promise<boolean>, scope?: SearchScope_2): Promise<Member_2[]>
Parameters
- predicate
-
(member: Member_2) => Promise<boolean>
Find calls predicate for each member of the installation.
- scope
- SearchScope
The scope to find members from the installations (personal chat, group chat, Teams channel).
Returns
Promise<Member[]>
An array of Member where predicate is true, and empty array otherwise.
findChannel((channel: Channel_2, teamDetails: undefined | TeamDetails) => Promise<boolean>)
Return the first Channel where predicate is true, and undefined otherwise.
(Ensure the bot app is installed into the General
channel, otherwise undefined will be returned.)
function findChannel(predicate: (channel: Channel_2, teamDetails: undefined | TeamDetails) => Promise<boolean>): Promise<undefined | Channel_2>
Parameters
- predicate
-
(channel: Channel_2, teamDetails: undefined | TeamDetails) => Promise<boolean>
Find calls predicate once for each channel of the installation,
until it finds one where predicate returns true. If such a channel is found, find
immediately returns that channel. Otherwise, find returns undefined
.
Returns
Promise<undefined | Channel>
The first Channel where predicate is true, and undefined
otherwise.
findMember((member: Member_2) => Promise<boolean>, SearchScope_2)
Return the first Member where predicate is true, and undefined otherwise.
function findMember(predicate: (member: Member_2) => Promise<boolean>, scope?: SearchScope_2): Promise<undefined | Member_2>
Parameters
- predicate
-
(member: Member_2) => Promise<boolean>
Find calls predicate once for each member of the installation, until it finds one where predicate returns true. If such a member is found, find immediately returns that member. Otherwise, find returns undefined.
- scope
- SearchScope
The scope to find members from the installations (personal chat, group chat, Teams channel).
Returns
Promise<undefined | Member>
The first Member where predicate is true, and undefined
otherwise.
getPagedInstallations(number, string, boolean)
Gets a pagined list of targets where the bot is installed.
function getPagedInstallations(pageSize?: number, continuationToken?: string, validationEnabled?: boolean): Promise<PagedData<TeamsBotInstallation_2>>
Parameters
- pageSize
-
number
Suggested number of entries on a page.
- continuationToken
-
string
A continuation token.
- validationEnabled
-
boolean
Returns
Promise<PagedData<TeamsBotInstallation>>
An array of TeamsBotInstallation with paged data and continuation token.
Remarks
The result is retrieving from the persisted storage.
installations()
Warning
This API is now deprecated.
Use getPagedInstallations instead.
Get all targets where the bot is installed.
function installations(): Promise<TeamsBotInstallation_2[]>
Returns
Promise<TeamsBotInstallation[]>
An array of TeamsBotInstallation.
Remarks
The result is retrieving from the persisted storage.
validateInstallation(Partial<ConversationReference>)
Validate the installation by getting paged memebers.
function validateInstallation(conversationReference: Partial<ConversationReference>): Promise<boolean>
Parameters
- conversationReference
-
Partial<ConversationReference>
The bound ConversationReference
.
Returns
Promise<boolean>
Returns false if recieves BotNotInConversationRoster
error, otherwise returns true.