@microsoft/teams.api
Version:
<p> <a href="https://www.npmjs.com/package/@microsoft/teams.api" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.api/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.api?activeTab=code" t
425 lines (422 loc) • 15 kB
text/typescript
import { ChannelID } from '../models/channel-id.mjs';
import { Account, ConversationAccount } from '../models/account.mjs';
import { ConversationReference } from '../models/conversation/conversation-reference.mjs';
import { Entity } from '../models/entity/index.mjs';
import { ChannelData } from '../models/channel-data/index.mjs';
import { MeetingInfo } from '../models/meeting/meeting-info.mjs';
import { TeamInfo } from '../models/channel-data/team-info.mjs';
import { NotificationInfo } from '../models/channel-data/notification-info.mjs';
import { CitationAppearance } from '../models/entity/citation-entity.mjs';
import { SensitivityUsageInfo } from '../models/entity/sensitivity-usage-info.mjs';
import { ChannelInfo } from '../models/channel-data/channel-info.mjs';
import { TenantInfo } from '../models/channel-data/tenant-info.mjs';
import '../models/agentic-identity.mjs';
import '../models/conversation-type.mjs';
import '../models/membership-source.mjs';
import '../models/membership-source-types.mjs';
import '../models/membership-types.mjs';
import '../models/role.mjs';
import '../models/entity/ai-message-entity.mjs';
import '../models/entity/message-entity.mjs';
import '../models/entity/client-info-entity.mjs';
import '../models/entity/mention-entity.mjs';
import '../models/entity/product-info-entity.mjs';
import '../models/entity/quoted-reply-entity.mjs';
import '../models/entity/sensitive-usage-entity.mjs';
import '../models/entity/stream-info-entity.mjs';
import '../models/entity/targeted-message-info-entity.mjs';
import '../models/channel-data/app-info.mjs';
import '../models/channel-data/chat-info.mjs';
import '../models/channel-data/feedback-loop.mjs';
import '../models/channel-data/on-behalf-of.mjs';
import '../models/channel-data/reply-chain-info.mjs';
import '../models/channel-data/settings.mjs';
import '../models/channel-data/source-info.mjs';
import '../models/meeting/meeting-details.mjs';
interface IActivity<T extends string = string> {
/**
* Contains the type of the activity.
*/
readonly type: T;
/**
* Contains an ID that uniquely identifies the activity on the channel.
*/
id: string;
/**
* Contains the URL that specifies the channel's service endpoint. Set by the channel.
*/
serviceUrl?: string;
/**
* Contains the date and time that the message was sent, in UTC, expressed in ISO-8601 format.
*/
timestamp?: Date;
/**
* A locale name for the contents of the text field.
* The locale name is a combination of an ISO 639 two- or three-letter culture code associated
* with a language
* and an ISO 3166 two-letter subculture code associated with a country or region.
* The locale name can also correspond to a valid BCP-47 language tag.
*/
locale?: string;
/**
* Contains the local date and time of the message, expressed in ISO-8601 format.
*
* For example, 2016-09-23T13:07:49.4714686-07:00.
*/
localTimestamp?: Date;
/**
* Contains an ID that uniquely identifies the channel. Set by the channel.
*/
channelId: ChannelID;
/**
* Identifies the sender of the message.
*/
from: Account;
/**
* Identifies the conversation to which the activity belongs.
*/
conversation: ConversationAccount;
/**
* A reference to another conversation or activity.
* @deprecated This will be removed by end of summer 2026.
*/
relatesTo?: ConversationReference;
/**
* Identifies the recipient of the message.
*/
recipient: Account;
/**
* Contains the ID of the message to which this message is a reply.
*/
replyToId?: string;
/**
* Represents the entities that were mentioned in the message.
*/
entities?: Entity[];
/**
* Contains channel-specific content.
*/
channelData?: ChannelData;
/**
* Information about the channel in which the message was sent.
*/
get channel(): ChannelInfo | undefined;
/**
* Information about the team in which the message was sent.
*/
get team(): TeamInfo | undefined;
/**
* Information about the tenant in which the message was sent.
*/
get meeting(): MeetingInfo | undefined;
/**
* Notification settings for the message.
*/
get notification(): NotificationInfo | undefined;
/**
* is this a streaming activity
*/
isStreaming(): boolean;
}
/**
* Base shape for an OUTBOUND activity the app constructs and sends.
*
* This is intentionally not derived from all of {@link IActivity}: inbound/server-filled
* fields such as `from`, `conversation`, `channelId`, `serviceUrl`, and timestamps are
* filled by the sender or service, not by callers constructing outbound input.
*/
interface IActivityInput<T extends string = string> {
/**
* Activity type discriminator.
*/
readonly type: T;
/**
* Optional activity ID used when updating an existing sent activity.
*/
id?: string;
/**
* Optional recipient account. Set `isTargeted` through {@link ActivityInput.withRecipient}
* when sending a targeted message.
*/
recipient?: Account;
/**
* ID of the activity this outbound activity replies to.
*/
replyToId?: string;
/**
* Entities attached to the outbound activity.
*/
entities?: Entity[];
/**
* Channel-specific metadata for the outbound activity.
*/
channelData?: ChannelData;
}
/**
* Base builder for outbound activity inputs.
*/
declare class ActivityInput<T extends string = string> implements IActivityInput<T> {
/**
* Activity type discriminator.
*/
readonly type: T;
/**
* Optional activity ID used when updating an existing sent activity.
*/
id?: string;
/**
* Optional recipient account.
*/
recipient?: Account;
/**
* ID of the activity this outbound activity replies to.
*/
replyToId?: string;
/**
* Entities attached to the outbound activity.
*/
entities?: Entity[];
/**
* Channel-specific metadata for the outbound activity.
*/
channelData?: ChannelData;
/**
* Create an outbound activity input.
* @param type - Activity type discriminator.
* @param value - Initial outbound activity fields.
*/
constructor(type: T, value?: Omit<Partial<IActivityInput<T>>, 'type'>);
/**
* Set the activity ID for update scenarios.
* @param value - Activity ID.
*/
withId(value: string): this;
/**
* Set the activity recipient.
* @param value - Recipient account.
* @param isTargeted - Whether the activity is targeted only to this recipient.
*/
withRecipient(value: Account, isTargeted?: boolean): this;
/**
* Merge channel-specific metadata into the outbound activity.
* @param value - Channel metadata to merge.
*/
withChannelData(value: ChannelData): this;
/**
* Add an entity to the outbound activity.
* @param value - Entity to add.
*/
addEntity(value: Entity): this;
/**
* Add multiple entities to the outbound activity.
* @param value - Entities to add.
*/
addEntities(...value: Entity[]): this;
/**
* Add the `Generated By AI` label.
*/
addAiGenerated(): this;
/**
* Add a Microsoft Purview sensitivity label to the message.
* Replaces any label previously added.
* @param label - The sensitivity label, identified by its Purview label ID.
*/
addSensitivityLabel(label: SensitivityUsageInfo): this;
/**
* Enable message feedback.
* @param mode - `'default'` shows Teams' built-in thumbs up/down UI.
* `'custom'` triggers a `message/fetchTask` invoke so the bot can return its own task module dialog.
*/
addFeedback(mode?: 'default' | 'custom'): this;
/**
* Add citations
* @param position - Citation position in the message text.
* @param appearance - Citation appearance metadata.
*/
addCitation(position: number, appearance: CitationAppearance): this;
/**
* Add a targeted message info entity for prompt preview.
* Skips if already present.
*
* @param messageId the message ID of the targeted message
*/
addTargetedMessageInfo(messageId: string): this;
/**
* Determine whether the activity contains stream metadata.
*/
isStreaming(): boolean;
/**
* Get or create the base message entity.
* There should only be one root level message entity.
*/
private ensureSingleRootLevelMessageEntity;
private isRootLevelMessageEntity;
private mergeRootLevelMessageEntity;
}
declare class Activity<T extends string = string> implements IActivity<T> {
/**
* Contains the type of the activity.
*/
readonly type: T;
/**
* Contains an ID that uniquely identifies the activity on the channel.
*/
id: string;
/**
* Contains the URL that specifies the channel's service endpoint. Set by the channel.
*/
serviceUrl?: string;
/**
* Contains the date and time that the message was sent, in UTC, expressed in ISO-8601 format.
*/
timestamp?: Date;
/**
* A locale name for the contents of the text field.
* The locale name is a combination of an ISO 639 two- or three-letter culture code associated
* with a language
* and an ISO 3166 two-letter subculture code associated with a country or region.
* The locale name can also correspond to a valid BCP-47 language tag.
*/
locale?: string;
/**
* Contains the local date and time of the message, expressed in ISO-8601 format.
*
* For example, 2016-09-23T13:07:49.4714686-07:00.
*/
localTimestamp?: Date;
/**
* Contains an ID that uniquely identifies the channel. Set by the channel.
*/
channelId: ChannelID;
/**
* Identifies the sender of the message.
*/
from: Account;
/**
* Identifies the conversation to which the activity belongs.
*/
conversation: ConversationAccount;
/**
* A reference to another conversation or activity.
* @deprecated This will be removed by end of summer 2026.
*/
relatesTo?: ConversationReference;
/**
* Identifies the recipient of the message.
*/
recipient: Account;
/**
* Contains the ID of the message to which this message is a reply.
*/
replyToId?: string;
/**
* Represents the entities that were mentioned in the message.
*/
entities?: Entity[];
/**
* Contains channel-specific content.
*/
channelData?: ChannelData;
/**
* Information about the tenant in which the message was sent.
*/
get tenant(): TenantInfo | undefined;
/**
* Information about the channel in which the message was sent.
*/
get channel(): ChannelInfo | undefined;
/**
* Information about the team in which the message was sent.
*/
get team(): TeamInfo | undefined;
/**
* Information about the tenant in which the message was sent.
*/
get meeting(): MeetingInfo | undefined;
/**
* Notification settings for the message.
*/
get notification(): NotificationInfo | undefined;
constructor(value: Pick<IActivity<T>, 'type'> & Partial<Omit<IActivity<T>, 'type'>>);
static from(activity: IActivity): Activity<string>;
toInterface(): IActivity;
clone(options?: Omit<Partial<IActivity>, 'type'>): Activity<string>;
withId(value: string): this;
withChannelId(value: ChannelID): this;
withFrom(value: Account): this;
withConversation(value: ConversationAccount): this;
/**
* @deprecated This will be removed by end of summer 2026.
*/
withRelatesTo(value: ConversationReference): this;
/**
* Set the recipient of this activity, optionally marking it as a targeted message.
* Targeted messages are ephemeral to the specified recipient in a shared conversation.
* @param value - The recipient account
* @param isTargeted - If true, marks this as a targeted message visible only to the recipient (default: false)
* @returns this instance for chaining
*
* @deprecated Use ActivityInput/MessageActivityInput/TypingActivityInput when constructing outbound activities.
*/
withRecipient(value: Account, isTargeted?: boolean): this;
withServiceUrl(value: string): this;
withTimestamp(value: Date): this;
withLocale(value: string): this;
withLocalTimestamp(value: Date): this;
/**
* @deprecated Use ActivityInput/MessageActivityInput/TypingActivityInput when constructing outbound activities.
*/
withChannelData(value: ChannelData): this;
/**
* Add an entity.
*/
addEntity(value: Entity): this;
/**
* Add multiple entities
*/
addEntities(...value: Entity[]): this;
/**
* Add the `Generated By AI` label.
*
* @deprecated Use ActivityInput/MessageActivityInput/TypingActivityInput when constructing outbound activities.
*/
addAiGenerated(): this;
/**
* Enable message feedback.
* @param mode - `'default'` shows Teams' built-in thumbs up/down UI.
* `'custom'` triggers a `message/fetchTask` invoke so the bot can return its own task module dialog.
*
* @deprecated Use ActivityInput/MessageActivityInput/TypingActivityInput when constructing outbound activities.
*/
addFeedback(mode?: 'default' | 'custom'): this;
/**
* Add citations
*
* @deprecated Use ActivityInput/MessageActivityInput/TypingActivityInput when constructing outbound activities.
*/
addCitation(position: number, appearance: CitationAppearance): this;
/**
* Add a targeted message info entity for prompt preview.
* Skips if already present. In reactive flows, `ctx.send()` and `ctx.reply()`
* populate this automatically — use this helper for proactive or deferred sends.
* An invalid or expired messageId causes the Teams service to silently drop the preview
* while still delivering the message.
*
* @param messageId the message ID of the targeted message (from the incoming activity's `id`)
*
* @deprecated Use ActivityInput/MessageActivityInput/TypingActivityInput when constructing outbound activities.
*/
addTargetedMessageInfo(messageId: string): this;
/**
* is this a streaming activity
*/
isStreaming(): boolean;
/**
* Get or create the base message entity.
* There should only be one root level message entity.
*/
private ensureSingleRootLevelMessageEntity;
private isRootLevelMessageEntity;
private mergeRootLevelMessageEntity;
}
export { Activity, ActivityInput, type IActivity, type IActivityInput };