API.AI - Conversational User Interface


https://console.api.ai/

  • 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"
  Trigger=Entry;
  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:
https://api.ai/blog/2015/11/23/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/key-concepts
https://docs.api.ai/docs/get-started -- Create Intent

API.AI "How to design" examples:
Number Genie - Simple conversation number guess game:
https://developers.google.com/actions/develop/apiai/tutorials/number-genie
Facts about Google - Simple conversation action with fulfillment:
https://developers.google.com/actions/develop/apiai/tutorials/google-facts
https://github.com/actions-on-google/apiai-facts-about-google-nodejs

Google Home "one click" "Actions on Google Integration":
https://docs.api.ai/docs/actions-on-google-integration

Actions on Google - Voice User Interface - Design Principles and Methodology
https://developers.google.com/actions/design/principles

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:
https://developers.google.com/actions/develop/apiai/tutorials/google-facts
https://github.com/actions-on-google/apiai-facts-about-google-nodejs

Voice to Natural language processing: Node.js
https://github.com/api-ai/api-ai-node-js/blob/master/examples/voice_request.js


No comments:

Post a Comment