UNPKG

botbuilder-dialogs

Version:

A dialog stack based conversation manager for Microsoft BotBuilder.

140 lines 6.33 kB
/** * @module botbuilder-dialogs */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { Activity, TurnContext } from 'botbuilder-core'; import { BeginSkillDialogOptions } from './beginSkillDialogOptions'; import { Dialog, DialogInstance, DialogReason, DialogTurnResult } from './dialog'; import { DialogContext } from './dialogContext'; import { SkillDialogOptions } from './skillDialogOptions'; /** * A specialized Dialog that can wrap remote calls to a skill. * * @remarks * The options parameter in beginDialog must be a BeginSkillDialogOptions instance * with the initial parameters for the dialog. */ export declare class SkillDialog extends Dialog<Partial<BeginSkillDialogOptions>> { protected dialogOptions: SkillDialogOptions; private readonly DeliveryModeStateKey; private readonly SkillConversationIdStateKey; /** * A sample dialog that can wrap remote calls to a skill. * * @remarks * The options parameter in `beginDialog()` must be a `SkillDialogArgs` object with the initial parameters * for the dialog. * * @param dialogOptions The options to execute the skill dialog. * @param dialogId The id of the dialog. */ constructor(dialogOptions: SkillDialogOptions, dialogId?: string); /** * Called when the skill dialog is started and pushed onto the dialog stack. * * @param dc The [DialogContext](xref:botbuilder-dialogs.DialogContext) for the current turn of conversation. * @param options Initial information to pass to the dialog. * @returns A Promise representing the asynchronous operation. * @remarks * If the task is successful, the result indicates whether the dialog is still active after the turn has been processed by the dialog. */ beginDialog(dc: DialogContext, options: BeginSkillDialogOptions): Promise<DialogTurnResult>; /** * Called when the skill dialog is _continued_, where it is the active dialog and the * user replies with a new [Activity](xref:botframework-schema.Activity). * * @param dc The [DialogContext](xref:botbuilder-dialogs.DialogContext) for the current turn of conversation. * @returns A Promise representing the asynchronous operation. * @remarks * If the task is successful, the result indicates whether the dialog is still * active after the turn has been processed by the dialog. The result may also contain a * return value. */ continueDialog(dc: DialogContext): Promise<DialogTurnResult>; /** * Called when the skill dialog is ending. * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) object for this turn. * @param instance State information associated with the instance of this dialog on the dialog stack. * @param reason [Reason](xref:botbuilder-dialogs.DialogReason) why the dialog ended. * @returns A Promise representing the asynchronous operation. */ endDialog(context: TurnContext, instance: DialogInstance, reason: DialogReason): Promise<void>; /** * Called when the skill dialog should re-prompt the user for input. * * @param context The [TurnContext](xref:botbuilder-core.TurnContext) object for this turn. * @param instance State information for this dialog. * @returns A Promise representing the asynchronous operation. */ repromptDialog(context: TurnContext, instance: DialogInstance): Promise<void>; /** * Called when a child skill dialog completed its turn, returning control to this dialog. * * @param dc The [DialogContext](xref:botbuilder-dialogs.DialogContext) for the current turn of the conversation. * @param _reason [Reason](xref:botbuilder-dialogs.DialogReason) why the dialog resumed. * @param _result Optional, value returned from the dialog that was called. The type * of the value returned is dependent on the child dialog. * @returns A Promise representing the asynchronous operation. */ resumeDialog(dc: DialogContext, _reason: DialogReason, _result?: any): Promise<DialogTurnResult>; /** * @protected * Validates the activity sent during continueDialog. * @remarks * Override this method to implement a custom validator for the activity being sent during the continueDialog. * This method can be used to ignore activities of a certain type if needed. * If this method returns false, the dialog will end the turn without processing the activity. * @param _activity The Activity for the current turn of conversation. * @returns True if the activity is valid, false if not. */ protected onValidateActivity(_activity: Activity): boolean; /** * @private * Clones the Activity entity. * @param activity Activity to clone. */ private cloneActivity; /** * @private */ private validateBeginDialogArgs; /** * @private */ private sendToSkill; /** * Tells us if we should intercept the OAuthCard message. * @remarks * The SkillDialog only attempts to intercept OAuthCards when the following criteria are met: * 1. An OAuthCard was sent from the skill * 2. The SkillDialog was called with a connectionName * 3. The current adapter supports token exchange * If any of these criteria are false, return false. * @private */ private interceptOAuthCards; /** * @private */ private sendTokenExchangeInvokeToSkill; /** * @private * Create a conversationId to interact with the skill and send the [Activity](xref:botframework-schema.Activity). * @param context [TurnContext](xref:botbuilder-core.TurnContext) for the current turn of conversation with the user. * @param activity [Activity](xref:botframework-schema.Activity) to send. * @returns The Skill Conversation ID. */ private createSkillConversationId; /** * @private * Gets the Skill Conversation ID from a given instance. * @param instance [DialogInstance](xref:botbuilder-dialogs.DialogInstance) from which to look for its ID. * @returns Instance conversation ID. */ private getSkillConversationIdFromInstance; } //# sourceMappingURL=skillDialog.d.ts.map