Compartir a través de


NotificationBot class

Provide utilities to send notification to varies targets (e.g., member, group, channel).

Constructors

NotificationBot(CloudAdapter, NotificationOptions_2)

Constructor of the notification bot.

Methods

buildTeamsBotInstallation(Partial<ConversationReference>)

Create a TeamsBotInstallation instance with conversation reference.

findAllChannels((channel: Channel, 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.)

findAllMembers((member: Member) => Promise<boolean>, SearchScope)

Return all Member where predicate is true, and empty array otherwise.

findChannel((channel: Channel, 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.)

findMember((member: Member) => Promise<boolean>, SearchScope)

Return 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.

validateInstallation(Partial<ConversationReference>)

Validate the installation by getting paged memebers.

Constructor Details

NotificationBot(CloudAdapter, NotificationOptions_2)

Constructor of the notification bot.

new NotificationBot(adapter: CloudAdapter, options?: NotificationOptions_2)

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

Parameters

conversationReference

Partial<ConversationReference>

The bound ConversationReference.

Returns

findAllChannels((channel: Channel, 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, teamDetails: undefined | TeamDetails) => Promise<boolean>): Promise<Channel[]>

Parameters

predicate

(channel: Channel, 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) => Promise<boolean>, SearchScope)

Return all Member where predicate is true, and empty array otherwise.

function findAllMembers(predicate: (member: Member) => Promise<boolean>, scope?: SearchScope): Promise<Member[]>

Parameters

predicate

(member: Member) => 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, 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, teamDetails: undefined | TeamDetails) => Promise<boolean>): Promise<undefined | Channel>

Parameters

predicate

(channel: Channel, 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) => Promise<boolean>, SearchScope)

Return the first Member where predicate is true, and undefined otherwise.

function findMember(predicate: (member: Member) => Promise<boolean>, scope?: SearchScope): Promise<undefined | Member>

Parameters

predicate

(member: Member) => 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>>

Parameters

pageSize

number

Suggested number of entries on a page.

continuationToken

string

A continuation token.

validationEnabled

boolean

Returns

An array of TeamsBotInstallation with paged data and continuation token.

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.