我想使用IBM Watson Conversation服务在Asp.Net平台上构建一个聊天机器人Web应用程序。我今天安装了IBM.WatsonDeveloperCloud Asp.Net软件包,但不知道我应该用它做什么,而且没有文档。解决方案中有大约50个项目,其中一个可用于所谓的简单聊天机器人Web应用程序?
答案 0 :(得分:1)
Watson Developer Cloud 包含使用Watson服务所需的所有文档,包括对话服务。
以下是使用对话的一些examples:
<强>安装强>
的NuGet
PM > Install-Package IBM.WatsonDeveloperCloud.Conversation.v1
Project.json
"dependencies": {
"IBM.WatsonDeveloperCloud.Conversation.v1": "1.2.0"
}
用法的
您完成以下步骤以实现您的应用程序:配置工作区。通过易于使用的图形环境,您可以为应用程序设置对话流和培训数据。开发您的应用程序您可以编写应用程序以通过API调用连接到Conversation工作区。
实例化和验证服务
在向服务发送请求之前,必须先对其进行实例化,并且必须设置凭据。
// create a Conversation Service instance
ConversationService _conversation = new ConversationService();
// set the credentials
_conversation.SetCredential(<username>, <password>);
发送消息:
// create message request
MessageRequest messageRequest0 = new MessageRequest()
{
Input = new InputData()
{
Text = <input-string0>
}
};
// send a message to the conversation instance
var result0 = _conversation.Message(<workspace-id>, messageRequest0);
// reference the message context to continue a conversation
messageRequest messageRequest1 = new MessageRequest()
{
Input = new InputData()
{
Text = <input-string1>
},
Context = result.Context
};
// Send another message including message context.
result1 = _conversation.Message(<workspace-id>, messageRequest1);
Obs。:在this link中有一个完整的指南,一步一步地将Watson Conversation Service与.Net
一起使用。