Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ContextValues<TContexts>

Type parameters

Hierarchy

  • ContextValues

Properties

Methods

Properties

input

input: TContexts

output

Methods

__@iterator

  • Returns the incoming contexts for this intent as an iterator.

    example
    
    const AppContexts = {
      NUMBER: 'number',
    }
    
    const app = dialogflow()
    
    app.intent('Default Welcome Intent', conv => {
      conv.contexts.set(AppContexts.NUMBER, 1)
      conv.ask('Welcome to action snippets! Say a number.')
    })
    
    // Create intent with 'number' context as requirement
    app.intent('Number Input', conv => {
      for (const context of conv.contexts) {
        // do something with the contexts
      }
    })
    example
    
    const AppContexts = {
      NUMBER: 'number',
    }
    
    const app = dialogflow()
    
    app.intent('Default Welcome Intent', conv => {
      conv.contexts.set(AppContexts.NUMBER, 1)
      conv.ask('Welcome to action snippets! Say a number.')
    })
    
    // Create intent with 'number' context as requirement
    app.intent('Number Input', conv => {
      for (const context of conv.contexts) {
        // do something with the contexts
      }
    })

    Returns IterableIterator<Context<Parameters>>

delete

  • delete(name: string): void

get

  • get(name: keyof TContexts): TContexts[keyof TContexts]
  • Returns the incoming context by name for this intent.

    example
    
    const AppContexts = {
      NUMBER: 'number',
    }
    
    const app = dialogflow()
    
    app.intent('Default Welcome Intent', conv => {
      conv.contexts.set(AppContexts.NUMBER, 1)
      conv.ask('Welcome to action snippets! Say a number.')
    })
    
    // Create intent with 'number' context as requirement
    app.intent('Number Input', conv => {
      const context = conv.contexts.get(AppContexts.NUMBER)
    })
    example
    
    const AppContexts = {
      NUMBER: 'number',
    }
    
    const app = dialogflow()
    
    app.intent('Default Welcome Intent', conv => {
      conv.contexts.set(AppContexts.NUMBER, 1)
      conv.ask('Welcome to action snippets! Say a number.')
    })
    
    // Create intent with 'number' context as requirement
    app.intent('Number Input', conv => {
      const context = conv.contexts.get(AppContexts.NUMBER)
    })

    Parameters

    • name: keyof TContexts

      The name of the Context to retrieve.

    Returns TContexts[keyof TContexts]

    Context value matching name or undefined if no matching context.

set

  • set(name: string, lifespan: number, parameters?: Parameters): void
  • Set a new context for the current intent.

    example
    
    const AppContexts = {
      NUMBER: 'number',
    }
    
    const app = dialogflow()
    
    app.intent('Default Welcome Intent', conv => {
      conv.contexts.set(AppContexts.NUMBER, 1)
      conv.ask('Welcome to action snippets! Say a number.')
    })
    
    // Create intent with 'number' context as requirement
    app.intent('Number Input', conv => {
      const context = conv.contexts.get(AppContexts.NUMBER)
    })
    example
    
    const AppContexts = {
      NUMBER: 'number',
    }
    
    const app = dialogflow()
    
    app.intent('Default Welcome Intent', conv => {
      conv.contexts.set(AppContexts.NUMBER, 1)
      conv.ask('Welcome to action snippets! Say a number.')
    })
    
    // Create intent with 'number' context as requirement
    app.intent('Number Input', conv => {
      const context = conv.contexts.get(AppContexts.NUMBER)
    })

    Parameters

    • name: string

      Name of the context. Dialogflow converts to lowercase.

    • lifespan: number

      Context lifespan.

    • Optional parameters: Parameters

      Context parameters.

    Returns void

Generated using TypeDoc