Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CallSession

Manages the bots conversation with a user.

Hierarchy

  • CallSession

Index

Constructors

constructor

Properties

conversationData

conversationData: any

Shared conversation data that's visible to all members of the conversation.

dialogData

dialogData: any

Data that's only visible to the current dialog.

library

library: Library

The bots root library of dialogs.

message

message: IEvent

The message recieved from the user. For bot originated messages this may only contain the "to" & "from" fields.

privateConversationData

privateConversationData: any

Private conversation data that's only visible to the user.

sessionState

sessionState: ISessionState

Sessions current state information.

userData

userData: any

Data for the user that's persisted across all conversations with the bot.

Methods

answer

beginDialog

  • Passes control of the conversation to a new dialog. The current dialog will be suspended until the child dialog completes. Once the child ends the current dialog will receive a call to dialogResumed() where it can inspect any results returned from the child.

    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 CallSession

dispatch

  • Dispatches a message for processing. The session will call any installed middleware before the message to the active dialog for processing.

    Parameters

    • sessionState: ISessionState

      The current session state. If null a new conversation will be started beginning with the configured dialogId.

    • message: IEvent

      The message to dispatch.

    Returns CallSession

endConversation

  • Ends the current conversation and optionally sends a message to the user. The call will be automatically hungup or rejected.

    Parameters

    • Optional action: string | string[] | IAction | IIsAction

      (Optional)

      • action: {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.
      • action: {string[]} - The sent message will be chosen at random from the array.
      • action: {IAction|IIsAction} - Action to send.
    • Rest ...args: any[]

      (Optional) arguments used to format the final output text when message is a {string|string[]}.

    Returns CallSession

endDialog

  • Ends the current dialog and optionally sends a message to the user. The parent will be resumed with an IDialogResult.resumed reason of completed.

    Parameters

    • Optional action: string | string[] | IAction | IIsAction

      (Optional)

      • action: {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.
      • action: {string[]} - The sent message will be chosen at random from the array.
      • action: {IAction|IIsAction} - Action to send.
    • Rest ...args: any[]

      (Optional) arguments used to format the final output text when message is a {string|string[]}.

    Returns CallSession

endDialogWithResult

error

  • Signals that an error occured. The bot will signal the error via an on('error', err) event.

    Parameters

    • err: Error

      Error that occured.

    Returns CallSession

gettext

  • gettext(msgid: string, ...args: any[]): string
  • Loads a localized string for the messages language. If arguments are passed the localized string will be treated as a template and formatted using sprintf-js (see their docs for details.)

    Parameters

    • msgid: string

      String to use as a key in the localized string table. Typically this will just be the english version of the string.

    • Rest ...args: any[]

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

    Returns string

hangup

  • Manually ends an established call. The call will be automatically ended when the bot stops prompting the user for input.

    Returns CallSession

isReset

  • isReset(): boolean

messageSent

  • messageSent(): boolean
  • Returns true if a message has been sent for this session.

    Returns boolean

ngettext

  • ngettext(msgid: string, msgid_plural: string, count: number): string
  • Loads the plural form of a localized string for the messages language. The output string will be formatted to include the count by replacing %d in the string with the count.

    Parameters

    • msgid: string

      Singular form of the string to use as a key in the localized string table. Use %d to specify where the count should go.

    • msgid_plural: string

      Plural form of the string to use as a key in the localized string table. Use %d to specify where the count should go.

    • count: number

      Count to use when determining whether the singular or plural form of the string should be used.

    Returns string

on

  • on(event: string, listener: Function): void
  • Registers an event listener.

    Parameters

    • event: string

      Name of the event. Event types:

    • listener: Function

      Function to invoke.

    Returns void

reject

replaceDialog

  • Ends the current dialog and starts a new one its place. The parent dialog will not be resumed until the new dialog completes.

    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 CallSession

reset

  • reset(dialogId?: string, dialogArgs?: any): CallSession
  • Clears the sessions callstack and restarts the conversation with the configured dialogId.

    Parameters

    • Optional dialogId: string

      (Optional) ID of the dialog to start.

    • Optional dialogArgs: any

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

    Returns CallSession

save

send

  • Sends a PlayPrompt action to the user.

    Parameters

    • action: string | string[] | IAction | IIsAction
      • action: {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.
      • action: {string[]} - The sent message will be chosen at random from the array.
      • action: {IAction|IIsAction} - Action to send.
    • Rest ...args: any[]

      (Optional) arguments used to format the final output text when action is a {string|string[]}.

    Returns CallSession

sendBatch

  • sendBatch(): void
  • Immediately ends the current batch and delivers any queued up messages.

    Returns void

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