JESSICA EARLEY: Have you ever talked to somebody
and noticed that they were thinking
on how to formulate a response?
Like they were really listening to you
and were figuring out what to say in return?
This is similar to how scenes work.
Processing users input and constructing a prompt
involves things like logic, [? evaluating ?] conditions,
seeing what data you have.
And to manage all of these elements you use scenes.
Scenes organize your conversations
into logical chunks.
You can think of them as similar to scenes
when they play our movie.
You can connect several scenes together
to create a user journey with each scene containing
its own logic.
There are different parts of the scene--
activation, execution, and transition.
Let's go over these concepts, and then a deeper dive.
Scenes are activated through scene transitions.
This can happen during an 10-match event
or conditional events.
After activation, a scene executes
within a well-defined lifecycle, which includes stages
like conditioning checking, slot filling, input consumption,
and prompt generation.
A scene executes in a loop until it meets some transition
criteria that you define.
You can cause transitions to happen
for things like slot filling completing,
an attempt being matched, and more.
A scene can transition to another scene
or to a special end conversation scene.
Basically, the scene is activated,
then the execution of the scene's lifecycle is processed,
and once the transition criteria is met,
the scene transitions to the next scene.
Now let's go in deeper on the different parts of a scene.
Scenes can be activated in several ways,
though only one scene can be activated at any time.
Scenes can be activated through intent matching, where
the user's input is matched with an intent that
activates the scene.
The most common example of this is when users first
invoke your action.
The user's input is matched to the main invocation system
intent, which will activate your first scene.
As the conversation continues, an intent
can be matched within the scene, which
will transition and activate the next scene.
Scenes can also be activated through
conditional transitions.
This is when a scene's transition criteria
is met and activates a new scene,
and deactivating the prior scene.
Any time that you're carrying out
logic in the Webhook Handler, you
can trigger a scene transition during runtime.
This gives you even more flexibility
in controlling scenes and the flow of your conversation.
Once the scene is active, let's go into the execution
of the lifecycle.
A scene's lifecycle operates in a loop
until a transition criteria is met.
So let's dive into the lifecycle.
When a scene is first activated, the On
enter lifecycle stage is activated.
Here, you can trigger a webhook event and add a prompt.
Prompts are added to the prompt queue.
The prompt queue will be delivered
to the user later in the lifecycle
and the On enter is only activated once,
and it's not part of the loop.
The next stage is where conditions are evaluated.
Conditions are defined by you, and when a condition is met,
it can trigger a webhook event.
Add a prompt to the prompt queue and can have it
transition, which will end this execution lifecycle.
If there isn't a transition, the next stage is slot filling.
Slot filling as a way to get particular data from the user.
You can think of it like filling a form.
If a scene has a slot that has not been filled,
the slot can trigger a webhook event
and add a prompt to the prompt queue.
If there's more than one slot that needs to be filled,
only the first is processed.
After slots, the next stage is prompts.
Prompts are delivered to the user
and the prompt queue is cleared.
Then the user can provide input, work its process,
and either fills a slot or matches an intent.
If the input filled the slot, then the scene execution
goes back to evaluate conditions and continues the loop.
If an intent is matched, it can trigger a webhook event
and add a prompt to the prompt queue.
Note that the intent can be a system's intent, global intent,
as well as a scenes custom intent.
If your intent match doesn't define your transition,
it goes back to conditions and continues the loop.
If the intent match does define a transition,
the scene transitions to the specific scene
taking along the prompt queue.
The last section is transitions.
Transitions are when you move from one scene to another.
From the prior example, you can have
a transition to a new scene during an intent match.
You can also have transitions when
certain conditions are met.
These transitions can go to another scene,
as well to system scenes.
System scenes are built in and are provided by the assistant.
These scenes are items like end conversation,
account linking, and more.
You might have noticed that there
are multiple places in a scene where you can trigger a webhook
event, add a prompt, and transition to different scenes.
This flexibility allows you to design conversations
to fit your use case, from a one-shot action
to a multi-turn action to a multi-invocation action.
Check out our best practices to see
different ways you can configure your conversation
model using scenes.
And of course, to learn more on scenes,
check out the Docs for requirements and details.
Join our Dev Community on Reddit,
where you can chat with other ActionsonGoogle Devs
and stay up to date by following us on Twitter.
I'm Jessica.
Thanks for watching, and I can't wait to see what you build.