Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Conversation<TUserStorage>

Type parameters

  • TUserStorage

Hierarchy

Properties

arguments

arguments: Arguments

available

available: Available

canvas

canvas: Canvas

device

device: Device

digested

digested: boolean = false

expectUserResponse

expectUserResponse: boolean = true

headers

headers: Headers

id

id: string

Gets the unique conversation ID. It's a new ID for the initial query, and stays the same until the end of the conversation.

example

app.intent('actions.intent.MAIN', conv => {
  const conversationId = conv.id
})

input

input: Input

noInputs

noInputs: (string | SimpleResponse)[] = []

Set reprompts when users don't provide input to this action (no-input errors). Each reprompt represents as the SimpleResponse, but raw strings also can be specified for convenience (they're passed to the constructor of SimpleResponse). Notice that this value is not kept over conversations. Thus, it is necessary to set the reprompts per each conversation response.

example

app.intent('actions.intent.MAIN', conv => {
  conv.noInputs = [
    'Are you still there?',
    'Hello?',
    new SimpleResponse({
      text: 'Talk to you later. Bye!',
      speech: '<speak>Talk to you later. Bye!</speak>'
    })
  ]
  conv.ask('What's your favorite color?')
})

request

responses

responses: Response[] = []

sandbox

sandbox: boolean

True if the app is being tested in sandbox mode. Enable sandbox mode in the Actions console to test transactions.

screen

screen: boolean

speechBiasing

speechBiasing: string[] = []

Sets speech biasing options.

example

app.intent('actions.intent.MAIN', conv => {
  conv.speechBiasing = ['red', 'blue', 'green']
  conv.ask('What is your favorite color out of red, blue, and green?')
})

surface

surface: Surface

type

type: Api.GoogleActionsV2ConversationType

user

user: User<TUserStorage>

Gets the User object. The user object contains information about the user, including a string identifier and personal information (requires requesting permissions, see conv.ask(new Permission)).

Methods

add

ask

  • Asks to collect user's input. All user's queries need to be sent to the app. The guidelines when prompting the user for a response must be followed at all times.

    example
    
    // Actions SDK
    const app = actionssdk()
    
    app.intent('actions.intent.MAIN', conv => {
      const ssml = '<speak>Hi! <break time="1"/> ' +
        'I can read out an ordinal like <say-as interpret-as="ordinal">123</say-as>. ' +
        'Say a number.</speak>'
      conv.ask(ssml)
    })
    
    app.intent('actions.intent.TEXT', (conv, input) => {
      if (input === 'bye') {
        return conv.close('Goodbye!')
      }
      const ssml = `<speak>You said, <say-as interpret-as="ordinal">${input}</say-as></speak>`
      conv.ask(ssml)
    })
    
    // Dialogflow
    const app = dialogflow()
    
    app.intent('Default Welcome Intent', conv => {
      conv.ask('Welcome to action snippets! Say a number.')
    })
    
    app.intent('Number Input', (conv, {num}) => {
      conv.close(`You said ${num}`)
    })

    Parameters

    • Rest responses: Response[]

      A response fragment for the library to construct a single complete response

    Returns this

close

  • Have Assistant render the speech response and close the mic.

    example
    
    // Actions SDK
    const app = actionssdk()
    
    app.intent('actions.intent.MAIN', conv => {
      const ssml = '<speak>Hi! <break time="1"/> ' +
        'I can read out an ordinal like <say-as interpret-as="ordinal">123</say-as>. ' +
        'Say a number.</speak>'
      conv.ask(ssml)
    })
    
    app.intent('actions.intent.TEXT', (conv, input) => {
      if (input === 'bye') {
        return conv.close('Goodbye!')
      }
      const ssml = `<speak>You said, <say-as interpret-as="ordinal">${input}</say-as></speak>`
      conv.ask(ssml)
    })
    
    // Dialogflow
    const app = dialogflow()
    
    app.intent('Default Welcome Intent', conv => {
      conv.ask('Welcome to action snippets! Say a number.')
    })
    
    app.intent('Number Input', (conv, {num}) => {
      conv.close(`You said ${num}`)
    })

    Parameters

    • Rest responses: Response[]

      A response fragment for the library to construct a single complete response

    Returns this

json

  • json<T>(json: T): this

response

  • response(): ConversationResponse

Generated using TypeDoc