在不更改工作区 ID 的情况下更新对话服务工作区
Update conversation service workspace without changing workspace ID
有没有办法在不更改工作区 ID 的情况下更新我的对话工作区?我需要不时地刷新我的舞台和产品工作区。我使用“导入”选项,但这会创建一个具有不同工作区 ID 的新工作区。这意味着我也需要在我的应用程序中进行更新。我知道我可以将它作为外部环境变量。但理想情况下,我也想避免这种情况。我只想要一种 "update" 现有工作区而不更改其 ID 的方法。
在案例中我知道有两种形式的 IBM Developers 示例。
.
1st: 有 .env
文件,您可以在其中添加 WORKSPACE_ID
而不需要在 "Environment Variables" 在 Watson 对话中。
用这个 Conversation simple - Nodejs and this Conversation enhanced - Java 检查 .env
示例文件
示例:
在 .env
文件中添加值:
# Environment variables
WORKSPACE_ID=<workspace-id>
CONVERSATION_USERNAME=<conversation-username>
CONVERSATION_PASSWORD=<conversation-password>
2nd:在代码中添加username
、password
和workspace_id
变量的值。
案例中的password
和username
是Service Credentials,在Conversation Service里面。
示例:
添加您的凭据和workspace_id - 简单对话 (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>'
检查新的工作区 API 功能。它将允许您以编程方式更新工作区而无需导入。
我建议在尝试使用它之前测试一下它是如何工作的。
有没有办法在不更改工作区 ID 的情况下更新我的对话工作区?我需要不时地刷新我的舞台和产品工作区。我使用“导入”选项,但这会创建一个具有不同工作区 ID 的新工作区。这意味着我也需要在我的应用程序中进行更新。我知道我可以将它作为外部环境变量。但理想情况下,我也想避免这种情况。我只想要一种 "update" 现有工作区而不更改其 ID 的方法。
在案例中我知道有两种形式的 IBM Developers 示例。 .
1st: 有 .env
文件,您可以在其中添加 WORKSPACE_ID
而不需要在 "Environment Variables" 在 Watson 对话中。
用这个 Conversation simple - Nodejs and this Conversation enhanced - Java 检查 .env
示例文件
示例:
在 .env
文件中添加值:
# Environment variables
WORKSPACE_ID=<workspace-id>
CONVERSATION_USERNAME=<conversation-username>
CONVERSATION_PASSWORD=<conversation-password>
2nd:在代码中添加username
、password
和workspace_id
变量的值。
案例中的password
和username
是Service Credentials,在Conversation Service里面。
示例:
添加您的凭据和workspace_id - 简单对话 (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>'
检查新的工作区 API 功能。它将允许您以编程方式更新工作区而无需导入。
我建议在尝试使用它之前测试一下它是如何工作的。