dialog module

Note

This namespace is in Beta and provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Namespace to interact with the dialog module-specific part of the SDK.

Interfaces

ISdkResponse

Data Structure to represent the SDK response when dialog closes

Type Aliases

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

Functions

isSupported()

Checks if dialog capability is supported by the host

open(UrlDialogInfo, DialogSubmitHandler, PostMessageChannel)

Allows app to open a url based dialog.

registerOnMessageFromParent(PostMessageChannel)

Register a listener that will be triggered when a message is received from the app that opened the dialog.

sendMessageToDialog(any)

Send message to the dialog from the parent

sendMessageToParentFromDialog(any)

Send message to the parent from dialog @remarks This function is only called from inside of a dialog

submit(string | object, string | string[])

Submit the dialog module and close the dialog

Function Details

isSupported()

Note

This API is in Beta and provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Checks if dialog capability is supported by the host

function isSupported(): boolean

Returns

boolean

boolean to represent whether dialog capabilty is supported

open(UrlDialogInfo, DialogSubmitHandler, PostMessageChannel)

Note

This API is in Beta and provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Allows app to open a url based dialog.

function open(urlDialogInfo: UrlDialogInfo, submitHandler?: DialogSubmitHandler, messageFromChildHandler?: PostMessageChannel)

Parameters

urlDialogInfo
UrlDialogInfo

An object containing the parameters of the dialog module.

submitHandler
DialogSubmitHandler

Handler that triggers when a dialog calls the submit(string | object, string | string[]) function or when the user closes the dialog.

messageFromChildHandler
PostMessageChannel

Handler that triggers if dialog sends a message to the app.

Remarks

This function cannot be called from inside of a dialog

registerOnMessageFromParent(PostMessageChannel)

Note

This API is in Beta and provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Register a listener that will be triggered when a message is received from the app that opened the dialog.

function registerOnMessageFromParent(listener: PostMessageChannel)

Parameters

listener
PostMessageChannel

The listener that will be triggered.

Remarks

This function is only called from inside of a dialog.

sendMessageToDialog(any)

Note

This API is in Beta and provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Send message to the dialog from the parent

function sendMessageToDialog(message: any)

Parameters

message

any

The message to send

sendMessageToParentFromDialog(any)

Note

This API is in Beta and provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Send message to the parent from dialog @remarks This function is only called from inside of a dialog

function sendMessageToParentFromDialog(message: any)

Parameters

message

any

The message to send to the parent

submit(string | object, string | string[])

Note

This API is in Beta and provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Submit the dialog module and close the dialog

function submit(result?: string | object, appIds?: string | string[])

Parameters

result

string | object

The result to be sent to the bot or the app. Typically a JSON object or a serialized version of it, If this function is called from a dialog while M365ContentAction is set in the context object by the host, result will be ignored

appIds

string | string[]

Valid application(s) that can receive the result of the submitted dialogs. Specifying this parameter helps prevent malicious apps from retrieving the dialog result. Multiple app IDs can be specified because a web app from a single underlying domain can power multiple apps across different environments and branding schemes.