Code Monkey home page Code Monkey logo

nationalparks_conversation's Introduction

nationalparks-conversation

Chatbots and Watson: Let’s talk about national parks: course source code

The chatbot uses Watson Conversation, Weather Company Data, React, Nodejs, and IBM Cloud to create a chatbot about National Parks.

The complete course content and videos lives here

Try the live demo here

Ask:

  • which parks can you talk about
  • Tell me about zion
  • What animals live there
  • What's the weather like
  • What animals live at Denali National Park
  • What's the weather like there

A glimpse

Prequisities

  1. Clone this repo
  2. Create an IBM Cloud account

Setup

Conversation

  • Provision an instance of Watson Conversation on IBM Cloud
  • Create a new conversation workspace by importing ./resources/conversation_workspace.json into your Watson Conversation workspaces,
  • Install client and server dependencies
  • Create .env files in the project root with the following contents
APP_ID=parks-conversation
PORT=3004
LOG_LEVEL=debug
SESSION_SECRET=test

WATSON_CONVERSATION_API_ROOT=https://gateway.watsonplatform.net/conversation/api
WATSON_CONVERSATION_VERSION=v1
WATSON_CONVERSATION_VERSION_DATE=2016-07-11
WATSON_CONVERSATION_USERNAME=<USERNAME>
WATSON_CONVERSATION_PASSWORD=<PASSWORD>
WATSON_CONVERSATION_WORKSPACE_ID=<WORKSPACE>

Server

Install server dependencies

npm install

Client

Install client dependencies

cd client
npm install

Build / Run (Development)

Build / Run (Production)

cd client
npm run build
cd ..
npm start

Navigate to http://localhost:3000

Deploy to IBM Cloud

Prequisites:

  • Install CloudFoundry Tools

Deploy

Follow the first 3 steps in the "Build / Run (Production)" section above, then run.

cf push USER_ID-nationalparks

Navigate to https://USER_ID-nationalparks.mybluemix.net

FAQ

Q: In Lab 5: "Programmatically interact with Watson Conversation", I get an authentication error. What do I do?

A: This occurs on Windows. Windows sets the USERNAME variable to the logged in OS user. Ultimately, it ends up overriding the value for USERNAME specified in .env. The problem can be solved in two ways:

  • on step 3., hard code the USERNAME and PASSWORD e.g.

    const conversation = new ConversationV1({
      	username: 'your-username',
      	password: 'your-password',
      	version_date: ConversationV1.VERSION_DATE_2016_09_20
      });

or

  • Rename the USERNAME env
    • Edit .env, change USERNAME to NP_USERNAME
    • in step 3., change USERNAME to NP_USERNAME

nationalparks_conversation's People

Contributors

cdimascio avatar rcauchon 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nationalparks_conversation's Issues

import workspace.json file to Watson Conversation tooling not correct

I am following the dw learning course to do the chatbot lab 6. I can successfully import the resources/conversation_workspace.json to Watson Conversation tooling, but when I go to the tooling to see the dialog, there is no response for the #listparks node, so I always get anything_else node response when I input something like "give a list of parks". It's different than the course. Is that correct ? It seems the Watson Conversation tooling has been upgraded so it's not compatible with the old workspace.json ?

Thanks!

Intents to be imported.

Thank you for the developerworks course and this example.
I imported the conversation json in the resources folder as my workspace. That created the intents, entities and dialog flow as well as expected.
I changed the conversation.js in the server code (commented the env) to get this working with IAM_apikey type of authentication and Watson Assistant.The conversation works perfectly. Please see below:

image

However, there is one issue with the intents as explained below. Please clarify.
When I type "Zion" instead of "Mount Zion" like above, the #tellmeabout intent is not detected. i.e; the response only has in #yes and @Nationalparks detected.
Eventually, in the discoursehandler.js that interprets the response, the default case of the switch case is triggered.
But this somehow results in "park" variable as undefined. Please see below.

image

Can you tell me the exact intents that you used for your application's (http://nationalparks.mybluemix.net/) workspace ?

I tried the workspace also directly and please find the intents detected.
image

image

TypeError: Cannot read property 'url' of undefined

TypeError: Cannot read property 'url' of undefined
at createRequest (C:\example_1\nationalparks_conversation\node_modules\watson-developer-cloud\lib\requestwrapper.js:168:45)
at ConversationV1.message (C:\example_1\nationalparks_conversation\node_modules\watson-developer-cloud\conversation\v1.js:221:10)
at createCbObservable (C:\example_1\nationalparks_conversation\node_modules\rx\dist\rx.async.js:268:6)
at C:\example_1\nationalparks_conversation\node_modules\rx\dist\rx.async.js:308:12
at Conversation.message (C:/example_1/nationalparks_conversation/server/api/services/conversation.js:21:12)
at DiscourseService.message (C:/example_1/nationalparks_conversation/server/api/services/discourse/index.js:10:8)
at Controller.messages (C:/example_1/nationalparks_conversation/server/api/controllers/conversation/controller.js:7:8)
at Layer.handle [as handle_request] (C:\example_1\nationalparks_conversation\node_modules\express\lib\router\layer.js:95:5)
at next (C:\example_1\nationalparks_conversation\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\example_1\nationalparks_conversation\node_modules\express\lib\router\route.js:112:3)
TypeError: Cannot read property 'url' of undefined
at createRequest (C:\example_1\nationalparks_conversation\node_modules\watson-developer-cloud\lib\requestwrapper.js:168:45)
at ConversationV1.message (C:\example_1\nationalparks_conversation\node_modules\watson-developer-cloud\conversation\v1.js:221:10)
at createCbObservable (C:\example_1\nationalparks_conversation\node_modules\rx\dist\rx.async.js:268:6)
at C:\example_1\nationalparks_conversation\node_modules\rx\dist\rx.async.js:308:12
at Conversation.message (C:/example_1/nationalparks_conversation/server/api/services/conversation.js:21:12)
at DiscourseService.message (C:/example_1/nationalparks_conversation/server/api/services/discourse/index.js:10:8)
at Controller.messages (C:/example_1/nationalparks_conversation/server/api/controllers/conversation/controller.js:7:8)
at Layer.handle [as handle_request] (C:\example_1\nationalparks_conversation\node_modules\express\lib\router\layer.js:95:5)
at next (C:\example_1\nationalparks_conversation\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\example_1\nationalparks_conversation\node_modules\express\lib\router\route.js:112:3)
TypeError: Cannot read property 'url' of undefined

App seems to be broken?

After cloning and installing on local, when I npm start, the app loads with UI but no "greeting". Also when I type "What parks can you tell me about?" and hit return, nothing appears in app UI and no response either. I have made sure all credentials are correct (username, password, workspace ID, etc).

Lab 5: Authentication Problem on Windows

Hello @cdimascio , I am currently trying to recreate the chatbot, but fail at module 41.

This is my error:

{ Error: Unauthorized: Access is denied due to invalid credentials.
...
code: 401,
error: 'Not Authorized',
description: '2018-05-25T11:14:24-05:00, Error ERCDPLTFRM-DNLKUPERR occurred when accessing https://gateway.watsonplatform.net/conversation/api/v1/workspaces/%3C86181bd0-cf0e-44a2-8eb5-c80bd2c2d5a1%3E/message?version=2016-09-20, Tran-Id: gateway01-59613562 - Invalid UserId and/or Password. Please confirm that your credentials match the end-point you are trying to access. A common error is trying to use credentials from an experimental or beta release against a GA release or vice versa',
body: 'Not Authorized',
'x-global-transaction-id': undefined }

I am very certain that I used the right credentials and workspace id. Is there an issue with the url or the new name of watson conversation to watson assistant? (BTW I do not really have any programming skills).

Thanks in advance!

Critical files required for programmatic calling

Hi @cdimascio,

I came here from your "Chatbots and Watson: Let’s talk about national parks" course, which is really great by the way. It was very difficult to find, but one of the better resources I've come across.

I've started a project from another GitHub repo (the IBM Watson assistant-simple one) and I would like to implement the programmatic calling aspect of this tutorial into that one.

I'm doing this so I can retrieve data from a database like this one allows you to do. I'm just a bit confused about the whole file structure.

What parts would I need to migrate over (as I can't seem to get it to work on my own)? Or do you think it might be better off to start my project over and use this as my base template?

Thanks in advance.

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.