Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ActionsSdkConversation<TConvData, TUserStorage>

Type parameters

  • TConvData

  • TUserStorage

Hierarchy

Constructors

constructor

Properties

arguments

arguments: Arguments

available

available: Available

body

data

data: TConvData

The session data in JSON format. Stored using conversationToken.

example

app.intent('actions.intent.MAIN', conv => {
  conv.data.someProperty = 'someValue'
})
example

app.intent('actions.intent.MAIN', conv => {
  conv.data.someProperty = 'someValue'
})

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
})
example

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

input

input: Input

intent

intent: string

Get the current Actions SDK intent.

example

app.intent('actions.intent.MAIN', conv => {
  const intent = conv.intent // will be 'actions.intent.MAIN'
})
example

app.intent('actions.intent.MAIN', conv => {
  const intent = conv.intent // will be 'actions.intent.MAIN'
})

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?')
})
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?')
})
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}`)
    })
    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}`)
    })
    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

serialize

Generated using TypeDoc