Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DialogAction

Dialog actions offer static shortcuts to implementing common actions. They also implement support for named actions which can be bound to a dialog to handle global utterances from the user like "help" or "cancel". Actions get pushed onto and off of the dialog stack as part of dialogs so these listeners can come into and out of scope as the conversation progresses. You can also bind named to actions to buttons which let your bot respond to button clicks on cards that have maybe scrolled off the screen.

Hierarchy

  • DialogAction

Index

Methods

Static beginDialog

  • Returns a closure that will passes control of the conversation to a new dialog.

    Type parameters

    • T

    Parameters

    • id: string

      Unique ID of the dialog to start.

    • Optional args: T

      (Optional) arguments to pass to the dialogs begin() method.

    Returns IDialogWaterfallStep

Static endDialog

Static send

  • Returns a closure that will send a simple text message to the user.

    Parameters

    • msg: string

      Text of the message to send. The message will be localized using the sessions configured localizer. If arguments are passed in the message will be formatted using sprintf-js (see the docs for details.)

    • Rest ...args: any[]

      (Optional) arguments used to format the final output string.

    Returns IDialogWaterfallStep

Static validatedPrompt

  • Returns a closure that wraps a built-in prompt with validation logic. The closure should be used to define a new dialog for the prompt using bot.add('/myPrompt', builder.DialogAction.)

    example
    
    var bot = new builder.BotConnectorBot();
    bot.add('/', [
        function (session) {
            session.beginDialog('/meaningOfLife', { prompt: "What's the meaning of life?" });
        },
        function (session, results) {
            if (results.response) {
                session.send("That's correct! The meaning of life is 42.");
            } else {
                session.send("Sorry you couldn't figure it out. Everyone knows that the meaning of life is 42.");
            }
        }
    ]);
    bot.add('/meaningOfLife', builder.DialogAction.validatedPrompt(builder.PromptType.text, function (response) {
        return response === '42';
    }));
    

    Parameters

    • promptType: PromptType

      Type of built-in prompt to validate.

    • validator: function

      Function used to validate the response. Should return true if the response is valid.

        • (response: any): boolean

    Returns Dialog

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method