Watson Conversation_Error in Environment Variable

2019-02-27 15:52发布

问题:

I am trying to copy Watson conversation simple node js application from GitHub (https://github.com/watson-developer-cloud/conversation-simple) and running in my local. I have created service key and setup workspace. Next I have updated Workspace ID, User ID & Password in .env, app.js file. I have imported existing car_workspace.json file only and used corresponding Workspace ID. While running in local host I am getting "The app has not been configured with a environment variable." Please help me to understand if I am missing anything.

回答1:

Try to use the .env file and make sure the are no spaces between = and the end of the line.

You need to have one file called .env, within the project from IBM Developers has one example, just delete the word: example, and the file will called just with .env in your Directory, like this image:

And replace the values with your Service Credentials and your Workspace_id

# Environment variables
WORKSPACE_ID=490a9b3b-xxxxxxxxxxxxx
CONVERSATION_USERNAME=xxxxxxxxxxxxxx-e1ebbc10
CONVERSATION_PASSWORD=Bxxxx6FdzXxL

Check another format:

USERNAME="yourUsername"

And in your app.js:

var workspace = process.env.WORKSPACE_ID || '<workspace-id>';
console.log(process.env.WORKSPACE_ID);//your value will appear

If you want, has another form, you can set the workspace_id and username, password in your app.js file.

var username = 'usernameServiceCredentials'
var password = 'passwordServiceCredentials'
var workspace_id = 'workspaceFromConversation'
  • See the dotenv documentation for more information.
  • You can see your Credentials inside your Workspace -> Deploy -> Credentials