Giter Club home page Giter Club logo

ibm / watson-assistant-slots-intro Goto Github PK

View Code? Open in Web Editor NEW
147.0 23.0 227.0 10.43 MB

A Chatbot for ordering a pizza that demonstrates how using the IBM Watson Assistant Slots feature, one can fill out an order, form, or profile.

Home Page: https://developer.ibm.com/patterns/assemble-a-pizza-ordering-chatbot-dialog/

License: Apache License 2.0

JavaScript 75.20% CSS 19.15% HTML 4.92% Shell 0.38% Dockerfile 0.35%
watson-conversation slot conversation-slots bluemix-service chatbot ibm-bluemix ibmcode

watson-assistant-slots-intro's Introduction

WARNING: This repository is no longer maintained

This repository will not be updated. The repository will be kept available in read-only mode.

Build Status

Creating a pizza ordering chatbot using Watson Assistant slots feature

In this Code Pattern, we will use the Watson Assistant Slots feature to build a chatbot that takes a pizza order. The needed information such as size, type, and ingredient choices can all be entered within one Assistant Node, unlike with previous versions of Assistant.

When the reader has completed this Code Pattern, they will understand how to:

  • Create a chatbot dialog with Watson Assistant
  • Use the power of Assistant Slots to more efficiently populate data fields
  • Use Assistant Slots to handle various inputs within one Node.

NOTE: This code pattern has been updated to include instructions for accessing Watson Assistant running on IBM Cloud Pak for Data. These updates can be found in the specific instructions for deploying your app locally, or deploying your app to OpenShift on IBM Cloud. The main change required is that your application will need additional credentials to access the IBM Cloud Pak for Data cluster that is hosting the Watson Assistant service.

Click here for more information about IBM Cloud Pak for Data.

"Architecture"

Flow

  1. User sends messages to the application (running locally or on IBM Cloud).
  2. The application sends the user message to IBM Watson Assistant service, and displays the ongoing chat in a web page.
  3. Watson Assistant uses the Slots feature to fill out the required fields for a pizza order, and sends requests for additional information back to the running application. Watson Assistant can be provisioned on either IBM Cloud or IBM Cloud Pak for Data.

Included Components

NOTE: This Code Pattern uses Watson Assistant experience. After October 8, 2021, all instances (non-standard) can switch between the classic and new Watson Assistant experiences by going to the upper-right corner of the Watson Assistant screen and clicking the Manage icon manage-icon located in the top-right corner of the Assistant screen. Click on Switch to classic experience or click on Switch to new experience in order to toggle between the two.

  • IBM Watson Assistant: Build, test and deploy a bot or virtual agent across mobile devices, messaging platforms, or even on a physical robot.

Featured technologies

  • Node.js: An asynchronous event driven JavaScript runtime, designed to build scalable applications.

Watch the Video

Using Cloud Foundry on IBM Cloud Using IBM Cloud's Kubernetes service
video "video"

Deployment options

Click on one of the options below for instructions on deploying the app.

public public openshift local

Assistant Slots Discussion

The power of Slots is in how it reduces the number of nodes required to implement logic in your Watson Assistant Dialog. Here's a partial conversation Dialog using the old method:

"Pizza dialog old way"

And here's a more complete Dialog using slots, which puts all the logic in the Pizza ordering Node.

"Pizza dialog new way"

Open up the Dialog, and we'll have a look:

"Pizza dialog begin"

Each slot represents a field to be populated in the chatbot: pizza_size, pizza_type, and pizza_topings. If they are not present, the user will be prompted, starting at the top, until all are populated via the associated variable ($pizza_size, $pizza_type, etc).

Click on the Configure "icon" to add more functionality:

"Pizza config 3 toppings"

Here, we can add a response for when this slot is filled (Found). Logic can be used for one ingredient:

"Pizza config 3 one topping"

or if there are greater than one ingredient added:

"Pizza config 3 >1 topping"

We've added logic to address yes or no answers to the question "Any extra toppings?":

"Pizza config 3 confirm not found"

Click on the 3 circles "icon" and choose Open JSON editor to edit the json directly:

"Pizza config edit JSON"

Here, we've set an empty value for the context: {"pizza_topings"} field, so that we can exit the loop by filling this slot.

Finally, we add responses for once the slots are all filled:

"Pizza order finish"

We start with the case where we have "pizza_toppings", by detecting that the array has size>0. Here, we first handle the case where the optional "pizza_place" slot is filled, and then handle the case where it is not.

"Pizza order finish no place"

Finally, we add a handler for the case where the user's answers to a prompt is not found. We've added a handler for the intent "help".

"Pizza handle Help"

We have a dialog node to handle the intent #reset which will reset all fields to null:

"Pizza reset node"

Assistant Example

Let's look at an example conversation and the associated json. With your Watson Pizzeria running, start a dialog and begin with telling the Pizza Bot you want a large pizza:

The 'User Input' shows you the "input"{"text"} field, as well as come of the "context" that is mostly used for Assistant to keep track of internal state. Scroll Down to Watson Understands and look at intents:

Note that the intent for "order" is detected. The entity "pizza_size" is now a slot that is filled out. We still have 2 required slots, "pizza_type" and "pizza_toppings". The user will be prompted until these are filled out:

We can now see that all required slots are filled:

What if we wanted to tell the Watson Pizzeria that we wanted to eat the pizza there, in the restaurant? Too late! the slot for "pizza_place" is optional, so the user won't be prompted for it, and once the required slots are filled, we exit the "Pizza Ordering" dialog node. The user needs to fill out optional slots first. Type reset to start again and test this by adding the phrase "to eat there...":

Troubleshooting

  • Deploy using Cloud Foundry cf push gives:

FAILED Could not find service <Watson_service> to bind to <IBM_Cloud_application>

If you name your service wcsi-conversation-service, this should work. When you use cf push, it is trying to bind to the services listed in the manifest.yml.

So, there are 2 ways you can get this to work:

  • Change the names of your IBM Cloud services to match the names in the manifest.
  • Change the names in the manifest to match the names of your IBM Cloud services.

NOTE: The Deploy to IBM Cloud button solves this issue by creating the services on the fly (with the correct names).

License

This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.

Apache Software License (ASL) FAQ

Links

Learn more

  • Artificial Intelligence Code Patterns: Enjoyed this Code Pattern? Check out our other AI Code Patterns.
  • AI and Data Code Pattern Playlist: Bookmark our playlist with all of our Code Pattern videos
  • With Watson: Want to take your Watson app to the next level? Looking to utilize Watson Brand assets? Join the With Watson program to leverage exclusive brand, marketing, and tech resources to amplify and accelerate your Watson embedded commercial solution.
  • Kubernetes on IBM Cloud: Deliver your apps with the combined the power of Kubernetes and Docker on IBM Cloud

watson-assistant-slots-intro's People

Contributors

akeller avatar dependabot[bot] avatar dolph avatar gihyeonlee avatar hisunah avatar imgbot[bot] avatar imgbotapp avatar jamaya2001 avatar kant avatar ljbennett62 avatar markstur avatar rhagarty avatar sanjeevghimire avatar scottdangelo avatar stevemar avatar stevemart avatar timroster avatar yamachan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

watson-assistant-slots-intro's Issues

Typo in Pizza type "quatro formagii"

I found a small typo in the Watson response, "quatro formagii" when asking for a pizza type. I think this needs to be "quatro formaggi".
Please correct the "quatro formagii" to "quatro formaggi" in 'data/watson-pizzeria.json'.

Conversation flow does not handle "No" extra toppings and does not reset

The #help handler set within the Pizza ordering node prevents the correct processing of a "no" response to extra toppings (entity @extra_confirmed:no) in the dialog slot. The current trained model created after the workspace is built matches a "no" response to the #help intent and returns the handler message instead of going to the correct "Not Found" item for the slot with a response based on the entity value. Example:

no_topping

The #reset handler set within the Pizza ordering node responds to confirm it will start over, but since the Reset node is never called, the attributes of the $pizza_ ... context variables are not reset and the slot dialog just continues.

reset_fail

Suggested fix:
By changing the default Digression processing for the Pizza ordering node, the #reset message handler can be eliminated entirely and allow the intended flow of the dialog to work for reset. Open settings on the node and select Digressions. Change the default to allow digressions from the node. Don't check "Only digress to slots that allow returns". Then delete the #reset handler in the Pizza ordering node.

One approach to better handle a "No" topping response after marking the Pizza ordering node as allowing Digressions to block digressions into the Fallback node. Then delete the #help handler in the Pizza ordering node. A drawback is that any ordering help apart from the slot prompts is lost, but this seems better than having the user stuck in an endless loop when trying to order a margherita pizza with no other toppings.

project missing .cfignore

When using a flow of running local, and then pushing to IBM Cloud with ibmcloud app push or cf push, the application fails to stage with a message:

Uploading files...
 10.99 MiB / 10.99 MiB [==========================================================================] 100.00% 9s

Waiting for API to complete processing files...
Job (fc6901b4-ec39-4bfe-8c1b-4b715e66b91a) failed: The app upload is invalid: Invalid zip archive.

This can be avoided by adding a .cfignore file excluding the node_modules folder/directory.

Incorrect config map name breaks application on k8s

The k8s deployment uses watson-pizzeria-pod.yml to get the WORKSPACE_ID from the config map, but incorrectly names the config map using watson-pizzeria.
The correct name should be watson-pizzeria-config.

environment variable "service_watson_conversation" is not set for deploying to docker option

Doing the container deployment option

After the deployment, found the following error in the log. Then review the steps and did not find environment variable "service_watson_conversation" is set anywhere.

++ jq -r .password
++ echo ''

  • export CONVERSATION_PASSWORD=
  • CONVERSATION_PASSWORD=
    ++ echo ''
    ++ jq -r .username
  • export CONVERSATION_USERNAME=
  • CONVERSATION_USERNAME=
  • echo 'CONVERSATION_USERNAME == '
  • echo 'CONVERSATION_PASSWORD == '
  • npm start
    CONVERSATION_USERNAME ==
    CONVERSATION_PASSWORD ==
    npm info it worked if it ends with ok
    npm info using [email protected]
    npm info using [email protected]
    npm info lifecycle [email protected]prestart: [email protected]
    npm info lifecycle [email protected]
    start: [email protected]
    > [email protected] start /usr/src/app
    > node server.js
    /usr/src/app/node_modules/watson-developer-cloud/lib/base_service.js:73
    throw new Error('Argument error: username and password are required unless use_unauthenticated is set');
    ^
    Error: Argument error: username and password are required unless use_unauthenticated is set
    at ConversationV1.BaseService.initCredentials (/usr/src/app/node_modules/watson-developer-cloud/lib/base_service.js:73:13)
    at ConversationV1.BaseService (/usr/src/app/node_modules/watson-developer-cloud/lib/base_service.js:44:18)
    at new ConversationV1 (/usr/src/app/node_modules/watson-developer-cloud/conversation/v1.js:31:15)
    at Object.value (/usr/src/app/node_modules/watson-developer-cloud/index.js:91:14)
    at Object.<anonymous> (/usr/src/app/app.js:40:27)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/src/app/server.js:22:14)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    npm info lifecycle [email protected]~start: Failed to exec start script
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] start: node server.js
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the [email protected] start script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    npm ERR! A complete log of this run can be found in:
    npm ERR! /root/.npm/_logs/2018-09-07T17_53_19_988Z-debug.log

Issues Deploying

I am having issues uploading the JSON file to IBM cloud. It says "Imported content must be valid JSON." Is this assistant still available with the changes to Watson Assistant?

old pizza order-watson conversation

Hi,
Could you share the link of "old pizza order-watson conversation", I'd like compare the difference between old and new(slots)

Thanks
Joe

Handling multiple values of context variables

Hello Everyone,

I am developing a pizza ordering chatbot. I have a context variable: 'pizza_type' which takes the value of type of pizza the user wants to order. It works fine if the user only orders 1 type of pizza. If the user works 2 or more pizzas, the chatbot only considers 1st pizza type and ignores rest of the entries. How do I solve this problem?

Can't find the Workspace ID

Using this instructions I can't find the workspace id, instead the info in View API Details is:

Skill details

Skill name:WatsonPizzeria
Skill ID:...
Legacy v1 workspace URL:...

Service credentials

Service credentials name:Auto-generated service credentials
API key:...

wcs-conversation-service binding

Got

FAILED
Could not find service wcsi-conversation-service to bind to watson-conversation-slots-intro

When I tried to "cf push"

Fixed it by moving it from manifest.yml, is that line necessary?

cannot deploy this app by toolchain

Hi,

I am having a problem at the very first step.
I cannot deploy this app by using toolchain.
First, it was said that I did not have an instance of Continuous Delivery, so I made it.
However, I cannot deploy it still. It was just said "start unsuccessful".
The log shows authentication and creating service instances are ok.

I would appreciate if you give me some advice or help.
(please tell me if I should add some more information or a part of the log.)

Thanks,
Mai

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.