Update conversation service workspace without changing workspace ID

帅比萌擦擦* 提交于 2019-12-12 02:13:30

问题


Is there a way to update my conversation workspace without changing the workspace ID? I need to refresh my stage and prod workspaces every now and then. I use the Import option, but that creates a new workspace with a different workspace ID. This means I need to go and update the same in my app as well. I know I can potentially have it as an external environment variable. But ideally, I would want to avoid that as well. I just want a way to "update" an existing workspace without changing its ID.


回答1:


Check the new Workspace API functionality. It will allow you to update a workspace programmatically without having to import.

I would recommend to test to see how it works before attempting to use it.




回答2:


In the case I know two forms with Examples of IBM Developers. .

1st: have the .env file, where you can add your WORKSPACE_ID and you don't need to be adding in the "Environment Variables" inside the Watson Conversation.

Check the .env example file with this Conversation simple - Nodejs and this Conversation enhanced - Java

Example:

Add the values inside .env file:

# Environment variables
WORKSPACE_ID=<workspace-id>
CONVERSATION_USERNAME=<conversation-username>
CONVERSATION_PASSWORD=<conversation-password>

2nd: Adding the value of the username, password, and workspace_id variables inside the code.

The password and the username in the case is the Service Credentials, inside Conversation Service.

Example:

Add your credentials and workspace_id - Conversation simple (app.js):

var conversation = new Conversation({
  // If unspecified here, the CONVERSATION_USERNAME and CONVERSATION_PASSWORD env properties will be checked
  // After that, the SDK will fall back to the bluemix-provided VCAP_SERVICES environment property
  // username: '<username>',  // add your username here
  // password: '<password>',  // add your password here
  url: 'https://gateway.watsonplatform.net/conversation/api',
  version_date: '2016-10-21',
  version: 'v1'
});

// Endpoint to be call from the client side
app.post('/api/message', function(req, res) {
  var workspace = process.env.WORKSPACE_ID || '<workspace-id>'; //if you dont added the value of workspace_id inside .env file, the app.js will try reconigze the value inside '<workspace-id>'


来源:https://stackoverflow.com/questions/42508848/update-conversation-service-workspace-without-changing-workspace-id

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