API.AI - Conversational User Interface


  • Sign in with google (integration with Google Home/Assistant/Allo?)
  • Create new Agent.
  • Settings - Restore from zip. (use reference/sample zip)
  • Add Fulfillment URL (if needed), and Check/enable "Use webhook", if/where needed.
  • Try it now (type & test)
  • Enable Integration: Assign (pronounceable) Invocation name, add Additional triggering intents, Authorize.
  • Try it on Actions on Google Web-Simulator.

Default / Fallback Intents

Default Welcome Intent: Initiate conversation to start a "Game"
  Input Context=None; Output Context=in_dialog flag.

Fallback Intents must have unique Input Context::

Unrecognized Deep Link Fallback: attempt to continue the conversation
  Trigger=Action called with unrecognized invocation argument;
  Input Context=inside Action/None; Output Context=Redirected to "Game" intent/in_dialog flag.
Default Fallback Intent: attempt to continue the conversation
  Trigger=Unrecognized argument during "Game";
  Input Context="Game"; Output Context="Game".
In Dialog Fallback: attempt to continue the conversation
  Trigger=in_dialog no other intent can be triggered;
  Input Context=in_dialog; Output Context=Redirected to "Game" intent/in_dialog flag.

TODO: Unrecognized Deep Link Fallback - Should the input context be something inside (and, not Welcome)?

Intent, Lifespan, Context

  • Intents can be triggered by Event names instead of User queries. (Welcome events are automatically supported for some one-click integrations).
  • Lifespan for a context is set on the Output Context in Intent. This is useful for retrying/resuming the conversation if user's response is invalid/not understood, by giving user chance(s) to make more attempt(s).
    • However, it could also create ambiguity and allow unexpected reentry into a state which has been handled/exited previously. For example: In Google-Facts sample, following sequence of response "history / quit / yes" shows "next fact" even after "quit" as the response "yes" gets handled in still alive "google-facts" context.
  • Output Context can also be set by webhook service app.js in ask() call:

  // Add google-facts context to outgoing context list
  assistant.setContext(GOOGLE_CONTEXT, DEFAULT_LIFESPAN, parameters);
  // Replace outgoing cat-facts context with lifespan = 0 to end it
  assistant.setContext(CAT_CONTEXT, END_LIFESPAN, {});
  assistant.ask('Looks like you\'ve heard all there is to know ' +
  'about cats. Would you like to hear about Google?');

Florist - Example walkthru

Florist Example: Using Contexts:

Intent transitions with output-context:

  • greetings -> compose (compose) -> yes-compose (yes-compose) -> yes-compose-choose (compose-add) -> yes-compose-choose-add (compose-add) [self loop]
  • greetings -> compose (compose) -> yes-compose (yes-compose) -> yes-compose-choose (compose-add) -> no-compose-choose-add (none)
  • greetings -> compose (compose) -> no-compose (no-compose) -> no-compose-anniversary (none)
  • greetings -> compose (compose) -> no-compose (no-compose) -> no-compose-birthday (none)

Florist - Agent - intent entries:

Intent: greetings
Context: none/none
Input: Hi; Hello
Response: Hello! Would you like to buy a bouquet?

Intent: compose
Context: none / compose, bouquet
Input: Yes; I want to buy a bouquet
Response: Would you like to compose the bouquet yourself?

Intent: yes-compose
Context: compose, bouquet / yes-compose, bouquet
Input: Yes; I want to make a bouquet myself.
Response: What kind of flowers would you like to add first?

Intent: yes-compose-choose
Context: yes-compose, bouquet / compose-add, bouquet
Input: Add @sys.number:amount-1 @sys.color:color-1 @flower:flower-1
Response: I put $amount-1 $color-1 $flower-1.original in your lovely bouquet. Should I add anything else?

Intent: yes-compose-choose-add
Context: compose-add, bouquet / compose-add, bouquet
Input: Add @sys.number:amount-2 @sys.color:color-2 @flower:flower-2
Response: I add $amount-2 $color-2 $flower-2.original to your bouquet. Anything else?

Intent: no-compose-choose-add
Context: compose-add, bouquet / none
Input: No; No, that's all
Response: You can purchase and get your wonderful bouquet at our office. Thank you for the order!

Intent: no-compose
Context: compose, bouquet / no-compose, bouquet
Input: No; No, give me usual bouquet
Response: I can offer you a bouquet for different occasions. For which occasion do you need a bouquet?

Intent: no-compose-anniversary
Context: no-compose, bouquet / none
Input: I need a bouquet for anniversary
Response: You can purchase and get the bouquet for anniversary at our office. Thank you for the order!

Intent: no-compose-birthday
Context: no-compose, bouquet / none
Input: I need a bouquet for birthday
Response: You can purchase and get the bouquet for birthday at our office. Thank you for the order!

More reading/links:

API.AI - Natural Language Interface
https://docs.api.ai/docs/get-started -- Create Intent

API.AI "How to design" examples:
Number Genie - Simple conversation number guess game:
Facts about Google - Simple conversation action with fulfillment:

Google Home "one click" "Actions on Google Integration":

Actions on Google - Voice User Interface - Design Principles and Methodology

Simple examples:
https://github.com/actions-on-google/apiai-silly-name-maker (sample without Fulfillment)
https://github.com/actions-on-google/apiai-silly-name-maker-webhook-nodejs (sample with Webhook Fulfillment)

Fulfillment, and continue Ask; Pass data between Api.ai and Webhook service:

Voice to Natural language processing: Node.js

No comments:

Post a Comment