Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ConversationV3

Represents a turn of the conversation. This is provided as conv in an intent handler.

Hierarchy

  • ConversationV3

Constructors

constructor

Properties

body

Represents a request sent to a developer's fulfillment by Google.

context

context: Context

Contains context information when user makes query. Such context includes but not limited to info about active media session, state of canvas web app, etc.

device

device: Device

Represents the device the user is using to make a request to the Action.

digested

digested: boolean = false

expected

expected: Expected

Describes the expectations for the next dialog turn.

handler

handler: Handler

Get the current handler information like handler name.

example

app.handle('handler name', conv => {
  const handlerName = conv.handler.name
})

headers

headers: Headers

home

home: Home

Represents the HomeGraph structure that the user's target device belongs to.

example
// Assign color to home storage
app.handle('storeColor', conv => {
  let color = 'red';
  conv.home.params.exampleColor = color;
});
    
// Retrieve color from home storage
app.handle('getStoredColor', conv => {
  let color = conv.home.params.exampleColor;
});
see

Home Storage documentation

intent

intent: Intent

Represents the last matched intent.

overwrite

overwrite: boolean = true

prompt

prompt: Prompt

Represents the prompts to be sent to the user, these prompts will be appended to previously added messages unless explicitly overwritten.

request

scene

scene: Scene

Info on the current and next scene when the function was called. Will be filled when the fulfillment call is made within the scope of a scene.

Represent a scene. Scenes can call fulfillment, add prompts, and collect slot values from the user. Scenes are triggered by events or intents and can trigger events and match intents to transition to other scenes.

Represents the current and next scene. If Scene.next is set the runtime will immediately transition to the specified scene.

session

session: Session

Holds session data like the session id and session parameters.

Contains information on the current conversation session

Describes data for the current session, session parameters can be created, updated, or removed by the fulfillment.

example
// Assign color to session storage
app.handle('storeColor', conv => {
  let color = 'red';
  conv.session.params.exampleColor = color;
});

// Retrieve color from session storage
app.handle('getStoredColor', conv => {
  let color = conv.session.params.exampleColor;
});
see

Session Storage documentation

user

user: User

Represents the user making a request to the Action.

example
// Assign color to user storage
app.handle('storeColor', conv => {
  let color = 'red';
  conv.user.params.exampleColor = color;
});

// Retrieve color from user storage
app.handle('getStoredColor', conv => {
  let color = conv.user.params.exampleColor;
});
see

User Storage documentation

Methods

add

  • Add prompt items to be sent back for fulfillment.

    Prompt items are limited to 2 simple responses. More than 2 will result in an error in fulfillment. The first simple added in order will be set to firstSimple. The last simple added in order will be set to lastSimple.

    example
    
    const app = conversation()
    
    app.handle('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.add(ssml)
    })
    

    Parameters

    • Rest ...promptItems: PromptItem[]

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

    Returns ConversationV3

append

  • Append speech responses to be sent back for fulfillment.

    example
    
    const app = conversation()
    
    app.handle('handler name', 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.append(ssml)
    })
    

    Parameters

    • speech: string

      A speech string to be appended

    Returns ConversationV3

json

response

serialize

Generated using TypeDoc