@microsoft/teams-js package

Classes

File

File object that can be used to represent image or video or audio

Media

Media object returned by the select Media API

VideoController

VideoController class is used to communicate between the app and the host client during the video capture flow

ChildAppWindow
LiveShareHost

Live Share host implementation for O365 and Teams clients.

ParentAppWindow

Interfaces

AppHostInfo

Represents information about the application's host.

AppInfo

Represents application information.

ChannelInfo

Represents Channel information.

ChatInfo

Represents Chat information.

Context

Represents structure of the received context message.

IExpectedFailureRequest

Represents the failure request sent during an erroneous app initialization.

IFailedRequest

Represents the failed request sent during a failed app initialization.

MeetingInfo

Represents Meeting information.

PageInfo

Represents Page information.

SharePointSiteInfo
TeamInfo

Represents Team information.

TenantInfo

Represents Tenant information.

UserInfo

Represents User information.

OpenAppInstallDialogParams
AuthenticatePopUpParameters

Describes the authentication pop-up parameters

AuthTokenRequestParameters

Describes authentication token request parameters

LegacyCallBacks
BarCodeConfig

Data structure to customize the barcode scanning experience in scanBarCode API. All properties in BarCodeConfig are optional and have default values in the platform

ComposeMeetingParams
OpenCalendarItemParams
StartCallParams
ISdkResponse

Data Structure to represent the SDK response when dialog closes

Location

Data struture to represent the location information

Location
LocationProps
ComposeMailBase

Base of a discriminated union between compose scenarios.

ComposeNewParams

Interfaces for each type.

ComposeReplyOrForwardParams
OpenMailItemParams
AssembleAttachment

Helper object to assembled media chunks

AudioProps

All properties in AudioProps are optional and have default values in the platform

BarCodeConfig

Barcode configuration supplied to scanBarCode API to customize barcode scanning experience in mobile All properties in BarCodeConfig are optional and have default values in the platform

ImageProps

All properties in ImageProps are optional and have default values in the platform

ImageUri

Input for view images API

MediaChunk

Media chunks an output of getMedia API from platform

MediaInputs

Input parameter supplied to the select Media API

MediaResult

Output of getMedia API from platform

VideoAndImageProps

All properties in VideoAndImageProps are optional and have default values in the platform

VideoControllerCallback

Callback which will register your app to listen to lifecycle events during the video capture flow

VideoProps

All properties in VideoProps are optional and have default values in the platform

IAppContentStageSharingCapabilities
IAppContentStageSharingState
IRaiseHandState

Interface for raiseHandState properties

ISpeakingState

Property bag for the speakingState changed event

LiveStreamState
MeetingReactionReceivedEventData

Property bag for the meeting reaction received event

RaiseHandStateChangedEventData

Property bag for the raiseHandState changed event

ActionMenuParameters
RemoveEvent

Describes the results of the settings.remove event. Includes notifySuccess, and notifyFailure to indicate the status of whether the settings.save call succeeded or not and why.

SaveEvent

Describes the results of the settings.save event. Includes result, notifySuccess, and notifyFailure to indicate the return object (result) and the status of whether the settings.save call succeeded or not and why.

SaveParameters

Parameters used in the settings.save event

NavigateWithinAppParams

Parameters for the NavigateWithinApp

InstanceConfig

Defines the configuration of the current or desired instance

NavigateToAppParams

Parameters for the NavigateToApp API

PeoplePickerInputs

Input parameter supplied to the People Picker API

PeoplePickerResult

Output user object of people picker API

Persona

The persona to show the profile for.

ShowProfileRequest

Input parameters provided to the showProfile API.

SearchQuery

This interface contains information pertaining to the contents of the host M365 application's search box

IBaseSharedContent
IShareRequest
IURLContent
StageViewParams

Parameters to open a stage view.

VideoFrame

Represents a video frame

VideoFrameConfig

Video frame configuration supplied to the host to customize the generated video frame parameters, like format

ActionInfo

Information common to all actions

BaseActionObject

Data pertaining to object(s) the action is being performed on

BotUrlDialogInfo

Data structure to describe dialog information needed to open a bot based dialog.

Context
DeepLinkParameters
DialogInfo

Data structure to describe dialog information

DialogSize

Data structure to represent the size of a dialog

FrameInfo
IAppWindow
LocaleInfo

Represents OS locale info used for formatting date and time data

M365ContentAction

Stores information needed to represent M365 Content stored in OneDrive or Sharepoint

OpenChatRequest

Describes information needed to start a chat

OpenGroupChatRequest

Used when starting a chat with more than one person

See OpenSingleChatRequest for use in a chat with only one person

OpenSingleChatRequest

Used when starting a chat with one person

See OpenGroupChatRequest for use when a chat with more than one person

SdkError
SecondaryId

Contains information on what Graph item is being queried

ShareDeepLinkParameters
ShowProfileRequestInternal
TabInformation

Represents information about tabs for an app

TabInstance

Represents information about a tab instance

TabInstanceParameters

Indicates information about the tab instance for filtering purposes.

TeamInformation

Represents Team Information

UrlDialogInfo

Data structure to describe dialog information needed to open a url based dialog.

Type Aliases

AuthenticateParameters
AuthTokenRequest
DialogSubmitHandler

Handler used for receiving results when a dialog closes, either the value passed by submit(string | object, string | string[]) or an error if the dialog was closed by the user.

PostMessageChannel

Handler used to receive and process messages sent between a dialog and the app that launched it

ComposeMailParams
Modality

The type of modalities that are supported when showing a profile. Can be provided as an optional hint with the request and will be respected if the hosting M365 application supports it.

PersonaIdentifiers

The set of identifiers that are supported for resolving the persona. At least one is required, and if multiple are provided then only the highest priority one will be used (AadObjectId > Upn > Smtp).

TriggerType

The type of the profile trigger.

  • MouseHover: The user hovered a target.
  • Press: The target was pressed with either a mouse click or keyboard key press.
  • AppRequest: The show profile request is happening programmatically, without direct user interaction.
SearchQueryHandler

This type will store the SearchQuery and allow other logic to be made inside the handler.

ContentType
IShareRequestContentType
VideoEffectCallBack

Video effect change call back function definition

VideoFrameCallback

Video frame call back function definition

FrameContext
Rectangle

Internal representation of a DOMRect suitable for sending via postMessage.

TaskInfo

Enums

ExpectedFailureReason

Describes expected errors that occurred during an otherwise successful app initialization

FailedReason

Describes errors that caused app initialization to fail

CallModalities
ComposeMailType
CameraStartMode

The modes in which camera can be launched in select Media API

FileFormat

Enum for file formats supported

ImageOutputFormats

Specifies the image output formats.

ImageUriType

ID contains a mapping for content uri on platform's side, URL is generic

MediaControllerEvent
MediaType

Specifies the type of Media

Source

Specifies the image source

CallType
MeetingReactionType

Different types of meeting reactions that can be sent/received

MeetingType
DisplayMode

Defines how a menu item should appear in the NavBar.

EffectChangeType

Video effect change type enum

VideoFrameFormat

Video frame format enum, currently only support NV12

ActionObjectType

Possible Action Types

ChannelType

The type of the channel with which the content is associated.

DialogDimension

Dialog module dimension enum

ErrorCode
FileOpenPreference

Allowed user file open preferences

FrameContexts
HostClientType
HostName
SecondaryM365ContentIdName

These correspond with field names in the MSGraph

TeamType

Indicates the team type, currently used to distinguish between different team types in Office 365 for Education (team types 1, 2, 3, and 4).

UserTeamRole

Indicates the various types of roles of a user in a team.

Functions

enablePrintCapability()
executeDeepLink(string, (status: boolean, reason?: string) => void)
getContext((context: Context) => void)
getMruTabInstances((tabInfo: TabInformation) => void, TabInstanceParameters)
getTabInstances((tabInfo: TabInformation) => void, TabInstanceParameters)
initialize(() => void, string[])
initializeWithFrameContext(FrameContext, () => void, string[])
navigateBack((status: boolean, reason?: string) => void)
navigateCrossDomain(string, (status: boolean, reason?: string) => void)
navigateToTab(TabInstance, (status: boolean, reason?: string) => void)
print()
registerAppButtonClickHandler(() => void)
registerAppButtonHoverEnterHandler(() => void)
registerAppButtonHoverLeaveHandler(() => void)
registerBackButtonHandler(() => boolean)
registerChangeSettingsHandler(() => void)
registerFullScreenHandler((isFullScreen: boolean) => void)
registerOnThemeChangeHandler((theme: string) => void)
returnFocus(boolean)
setFrameContext(FrameContext)
shareDeepLink(DeepLinkParameters)

Function Details

enablePrintCapability()

Warning

This API is now deprecated.

As of 2.0.0, please use teamsCore.enablePrintCapability(): void instead.

Enable print capability to support printing page using Ctrl+P and cmd+P

function enablePrintCapability()

Warning

This API is now deprecated.

As of 2.0.0, please use app.openLink(deepLink: string): Promise<void> instead.

Execute deep link API.

function executeDeepLink(deepLink: string, onComplete?: (status: boolean, reason?: string) => void)

Parameters

deepLink

string

deep link.

onComplete

(status: boolean, reason?: string) => void

getContext((context: Context) => void)

Warning

This API is now deprecated.

As of 2.0.0, please use app.getContext(): Promise<app.Context> instead.

Retrieves the current context the frame is running in.

function getContext(callback: (context: Context) => void)

Parameters

callback

(context: Context) => void

The callback to invoke when the Context object is retrieved.

getMruTabInstances((tabInfo: TabInformation) => void, TabInstanceParameters)

Warning

This API is now deprecated.

As of 2.0.0, please use pages.tabs.getMruTabInstances(tabInstanceParameters?: TabInstanceParameters): Promise<TabInformation> instead.

Allows an app to retrieve the most recently used tabs for this user.

function getMruTabInstances(callback: (tabInfo: TabInformation) => void, tabInstanceParameters?: TabInstanceParameters)

Parameters

callback

(tabInfo: TabInformation) => void

The callback to invoke when the TabInformation object is retrieved.

tabInstanceParameters
TabInstanceParameters

OPTIONAL Ignored, kept for future use

getTabInstances((tabInfo: TabInformation) => void, TabInstanceParameters)

Warning

This API is now deprecated.

As of 2.0.0, please use pages.tabs.getTabInstances(tabInstanceParameters?: TabInstanceParameters): Promise<TabInformation> instead.

Allows an app to retrieve for this user tabs that are owned by this app. If no TabInstanceParameters are passed, the app defaults to favorite teams and favorite channels.

function getTabInstances(callback: (tabInfo: TabInformation) => void, tabInstanceParameters?: TabInstanceParameters)

Parameters

callback

(tabInfo: TabInformation) => void

The callback to invoke when the TabInstanceParameters object is retrieved.

tabInstanceParameters
TabInstanceParameters

OPTIONAL Flags that specify whether to scope call to favorite teams or channels.

initialize(() => void, string[])

Warning

This API is now deprecated.

As of 2.0.0, please use app.initialize(validMessageOrigins?: string[]): Promise<void> instead.

Initializes the library. This must be called before any other SDK calls but after the frame is loaded successfully.

function initialize(callback?: () => void, validMessageOrigins?: string[])

Parameters

callback

() => void

Optionally specify a callback to invoke when Teams SDK has successfully initialized

validMessageOrigins

string[]

Optionally specify a list of cross frame message origins. There must have https: protocol otherwise they will be ignored. Example: https://www.example.com

initializeWithFrameContext(FrameContext, () => void, string[])

Warning

This API is now deprecated.

As of 2.0.0, please use pages.initializeWithFrameContext(frameInfo: FrameInfo, callback?: () => void, validMessageOrigins?: string[],): void instead.

Initialize with FrameContext

function initializeWithFrameContext(frameContext: FrameContext, callback?: () => void, validMessageOrigins?: string[])

Parameters

frameContext
FrameContext

FrameContext information to be set

callback

() => void

The optional callback to be invoked be invoked after initilizing the frame context

validMessageOrigins

string[]

Optionally specify a list of cross frame message origins. They must have https: protocol otherwise they will be ignored. Example: https:www.example.com

navigateBack((status: boolean, reason?: string) => void)

Warning

This API is now deprecated.

As of 2.0.0, please use pages.backStack.navigateBack(): Promise<void> instead.

Navigates back in the Teams client. See registerBackButtonHandler for more information on when it's appropriate to use this method.

function navigateBack(onComplete?: (status: boolean, reason?: string) => void)

Parameters

onComplete

(status: boolean, reason?: string) => void

The callback to invoke when the action is complete.

navigateCrossDomain(string, (status: boolean, reason?: string) => void)

Warning

This API is now deprecated.

As of 2.0.0, please use pages.navigateCrossDomain(url: string): Promise<void> instead.

Navigates the frame to a new cross-domain URL. The domain of this URL must match at least one of the valid domains specified in the validDomains block of the manifest; otherwise, an exception will be thrown. This function needs to be used only when navigating the frame to a URL in a different domain than the current one in a way that keeps the app informed of the change and allows the SDK to continue working.

function navigateCrossDomain(url: string, onComplete?: (status: boolean, reason?: string) => void)

Parameters

url

string

The URL to navigate the frame to.

onComplete

(status: boolean, reason?: string) => void

The callback to invoke when the action is complete.

navigateToTab(TabInstance, (status: boolean, reason?: string) => void)

Warning

This API is now deprecated.

As of 2.0.0, please use pages.tabs.navigateToTab(tabInstance: TabInstance): Promise<void> instead.

Navigates the Microsoft Teams app to the specified tab instance.

function navigateToTab(tabInstance: TabInstance, onComplete?: (status: boolean, reason?: string) => void)

Parameters

tabInstance
TabInstance

The tab instance to navigate to.

onComplete

(status: boolean, reason?: string) => void

The callback to invoke when the action is complete.

print()

Warning

This API is now deprecated.

As of 2.0.0, please use teamsCore.print(): void instead.

Default print handler

function print()

registerAppButtonClickHandler(() => void)

Warning

This API is now deprecated.

As of 2.0.0, please use pages.appButton.onClick(handler: () => void): void instead.

Registers a handler for clicking the app button. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

function registerAppButtonClickHandler(handler: () => void)

Parameters

handler

() => void

The handler to invoke when the personal app button is clicked in the app bar.

registerAppButtonHoverEnterHandler(() => void)

Warning

This API is now deprecated.

As of 2.0.0, please use pages.appButton.onHoverEnter(handler: () => void): void instead.

Registers a handler for entering hover of the app button. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

function registerAppButtonHoverEnterHandler(handler: () => void)

Parameters

handler

() => void

The handler to invoke when entering hover of the personal app button in the app bar.

registerAppButtonHoverLeaveHandler(() => void)

Warning

This API is now deprecated.

As of 2.0.0, please use pages.appButton.onHoverLeave(handler: () => void): void instead.

Registers a handler for exiting hover of the app button. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

function registerAppButtonHoverLeaveHandler(handler: () => void)

Parameters

handler

() => void

The handler to invoke when exiting hover of the personal app button in the app bar.

registerBackButtonHandler(() => boolean)

Warning

This API is now deprecated.

As of 2.0.0, please use pages.backStack.registerBackButtonHandler(handler: () => boolean): void instead.

Registers a handler for user presses of the Team client's back button. Experiences that maintain an internal navigation stack should use this handler to navigate the user back within their frame. If an app finds that after running its back button handler it cannot handle the event it should call the navigateBack method to ask the Teams client to handle it instead.

function registerBackButtonHandler(handler: () => boolean)

Parameters

handler

() => boolean

The handler to invoke when the user presses their Team client's back button.

registerChangeSettingsHandler(() => void)

Warning

This API is now deprecated.

As of 2.0.0, please use pages.config.registerChangeConfigHandler(handler: () => void): void instead.

Registers a handler for when the user reconfigurated tab.

function registerChangeSettingsHandler(handler: () => void)

Parameters

handler

() => void

The handler to invoke when the user click on Settings.

registerFullScreenHandler((isFullScreen: boolean) => void)

Warning

This API is now deprecated.

As of 2.0.0, please use pages.registerFullScreenHandler(handler: (isFullScreen: boolean) => void): void instead.

Registers a handler for changes from or to full-screen view for a tab. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

function registerFullScreenHandler(handler: (isFullScreen: boolean) => void)

Parameters

handler

(isFullScreen: boolean) => void

The handler to invoke when the user toggles full-screen view for a tab.

registerOnThemeChangeHandler((theme: string) => void)

Warning

This API is now deprecated.

As of 2.0.0, please use app.registerOnThemeChangeHandler(handler: (theme: string) => void): void instead.

Registers a handler for theme changes. Only one handler can be registered at a time. A subsequent registration replaces an existing registration.

function registerOnThemeChangeHandler(handler: (theme: string) => void)

Parameters

handler

(theme: string) => void

The handler to invoke when the user changes their theme.

returnFocus(boolean)

Warning

This API is now deprecated.

As of 2.0.0, please use pages.returnFocus(navigateForward?: boolean): void instead.

Return focus to the main Teams app. Will focus search bar if navigating foward and app bar if navigating back.

function returnFocus(navigateForward?: boolean)

Parameters

navigateForward

boolean

Determines the direction to focus in teams app.

setFrameContext(FrameContext)

Warning

This API is now deprecated.

As of 2.0.0, please use pages.setCurrentFrame(frameInfo: FrameInfo): void instead.

Set the current Frame Context

function setFrameContext(frameContext: FrameContext)

Parameters

frameContext
FrameContext

FrameContext information to be set

Warning

This API is now deprecated.

As of 2.0.0, please use pages.shareDeepLink(deepLinkParameters: DeepLinkParameters): void instead.

Shares a deep link that a user can use to navigate back to a specific state in this page.

function shareDeepLink(deepLinkParameters: DeepLinkParameters)

Parameters

deepLinkParameters
DeepLinkParameters

ID and label for the link and fallback URL.