Router
Expected Client Input
Whenever there is a new request to be processed by the Brain, the main service ZB will receive a user utterance U. Utterances are always transmitted in plain text. (In case of Speech communications, an external service will handle the Speech-to-Text conversation)
Due to HTML being stateless, a session variable that allows to track the current user (client) is also required. The Session ID is a unique identifier generated at client side (?) and transmitted as an argument (URL String ?argument) or as a http-Header (still to be defined)
Whenever identification of a specific microservice is predefined (e.g. the case of rrunning a Poll or a specific questionnaire such as Breast Risk Assessment), a Referral ID is passed as an argument. The referral ID is generated at Server Side and passed to the client for further communications.
Whenever neccessary, Zana Brain will make use of an Authentication Token. Authentication tokesn are used to allow a secure communication verified by the token. Such token is generated server side after a successful authentication (login). Such process is not foreseen in the short term. Input Variables
Zana Brains expects the following input variables:
- Utterance - U A user statement
- Session Id - SID An identifier for each client/users
- Referral Id - RID A specific use case used to bypass/fastforward to specific Zana-Service
- Authentication Token - AUTH-TOKEN A Token that authentifies a specific user / N/A
Router Pipeline
Upon receiving a set of inputs, Zana Brain follows a Routing Pipeline to identify the correct service responsible for returning an action (TODO: Define ACTION).
- Referral - Check if a referral condition is fulfilled and validated
- Context - A class that preserves information on the discourse context;
Scenario
- User asks: "What are is bruxism?" (SiD="$Autogenerated", P="mobile", U="What is Bruxism", RiD="", DialogContext="Empty")
- Router -
- Dialog Context - If empty, Create Dialog Context
- Dialog Context (InputIn (U),keyEntity="",List
)
- Dialog Context (InputIn (U),keyEntity="",List
- Create - ClientTurn T (SiD,TimeStamp,RiD,DialogContext,User)
- Client State -> new State(UserId, Turn)
- Information State -> Add State Reference if not exist
- POST /nlu/ic/
- Dialog Context - If empty, Create Dialog Context
POST https://api.zana.com/nlu/ic/
Headers:
Authorization: ""
Content-Type: application/json
POST body:
{
"utterance": "What is bruxism?",
"sid":"$Autogenerated",
"dialogContext": [
"Zana"
],
"timezone": "Europe/Tirana"
}
- NLU IC
- Identify Entities GET http://api.zana.com/nlu/er/query?text=What%20is%20Bruxism
{ "confidence":0.1, "name":"Teeth grinding", "score":9.6354885, "id":"c257", "synonymMatch":"", "type":"condition", "url":"/c/teeth-grinding.257", "image":null }
- Identify Entities GET http://api.zana.com/nlu/er/query?text=What%20is%20Bruxism
-
Classify Intent See: NLU Response
{ "id":"e6f9bd70-af66-11e8-96f8-529269fb1459", "sid": "23784867264", "timestamp": "2018-09-01T19:46:07.379Z", "intent": { "name": "IntentName", "matchedEntity": [{ "confidence": 0.9, "name": "Teeth grinding", "id": "c257", "synonymMatch": "", "type": "condition", "url": "/c/teeth-grinding.257", "image": null }], "outputContext": ["", "" ], "isFallback": false }, "dialogFlowEntities": { "name": ["heart attack ", "stroke "] }, "status": { "code": 200, "message": "Completed OK" } }
-
Router receives the Intent + Entities
- ASK DM
{ "sid":"$Autogenerated", "intentName":"IntroductionTeethGrinding", "entity":{ "id":"c257", "name":"Teeth Grinding", "type":"condition", "url":"/c/teeth-grinding.257" }, "dialogContext": { name:"Zana" }, "timestamp": "2017-09-19T21:16:44.832Z" }, "state":{ "user":"USERDATA", "turns":[ {},{},{} ] } }
- ASK DM
- Identifies operation is IR based on the IntentName!?
- Retrieves information from IR
- Sends back: