Watson Conversation_Error in Environment Variable

拜拜、爱过 提交于 2019-12-02 10:04:55

问题


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


来源:https://stackoverflow.com/questions/46105894/watson-conversation-error-in-environment-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!