简体   繁体   中英

How to implement “client” type action in IBM Watson Assistant client?

I'm working on IBM Watson Assistant service to build AI chatbot and currently I have building client side UI for that, So as per IBM's documentation they supports various actions to trigger external business logic using functions. I assume that "client" type action can help me to trigger some javascript function but I cannot see any working example on google. So please help me to implement "client" type action in my html/javascript client.

Check the question in this posting - https://developer.ibm.com/answers/questions/477020/help-with-custom-actions-for-ibm-watson-assistant/

There are two parts to client side actions. The first is in the dialog which signals that an action is required, and where the result of the action should be placed. Client side actions require you to have an orchestration layer. Which means that you are in control of both the dialog flow and the orchestration layer that is reacting. It is up to you how you get them to coordinate. You are not obliged to follow any pattern. The easiest way is to use the Context. The dialog sets a context variable eg. 'PleaseDoSomething', the application sees it and does something.

The documented Client Action construct is a specification that puts a structure to this process; Allows other orchestration layers to make sense of the action; Allows you to switch to Cloud Functions relatively easily.

If use the Client Action construct.

then the dialog json will look something like:

{
  "output": {
    "text": {
      "values": [
        "Hang on I need to look that up."
      ],
      "selection_policy": "sequential"
    },
    "actions": [
     {
       "name": "fetchBalance",
       "type": "client",
       "result_variable": "balance"
     }
   ]
  }
}

Your orchestration layer looks for 'Actions', runs 'fetchBalance' and puts the result in the context field 'balance'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM