With the IBM Watson™ Conversation service, you can create an application that understands natural-language input and uses machine learning to respond to customers in a way that simulates a conversation between humans.
PM > Install-Package IBM.WatsonDeveloperCloud.Conversation.v1
<ItemGroup>
<PackageReference Include="IBM.WatsonDeveloperCloud.Conversation.v1" Version="2.5.0" />
</ItemGroup>
You complete these steps to implement your application:
-
Configure a workspace. With the easy-to-use graphical environment, you set up the dialog flow and training data for your application.
-
Develop your application. You code your application to connect to the Conversation workspace through API calls. You then integrate your app with other systems that you need, including back-end systems and third-party services such as chat services or social media.
List existing workspaces for the service instance.
var result = _conversation.ListWorkspaces();
Create a new workspace.
CreateWorkspace workspace = new CreateWorkspace()
{
Name = <workspace-name>,
Description = <workspace-description>,
Language = <workspace-language>
};
var result = _conversation.CreateWorkspace(workspace);
Delete an existing workspace.
var result = _conversation.DeleteWorkspace(<workspace-id>);
Get detailed information about a specific workspace.
var result = _conversation.GetWorkspace(<workspace-id>);
Update an existing workspace.
UpdateWorkspace updatedWorkspace = new UpdateWorkspace()
{
Name = <updated-workspace-name>,
Description = <updated-workspace-description>,
Language = <updated-workspace-language>
};
var result = _conversation.UpdateWorkspace(<workspace-id>, updatedWorkspace);
Get a response to a user's input.
// 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);
List the counterexamples for a workspace. Counterexamples are examples that have been marked as irrelevant input.
var result = _conversation.ListCounterexamples(<workspaceId>);
Add a new counterexample to a workspace. Counterexamples are examples that have been marked as irrelevant input.
CreateExample example = new CreateExample()
{
Text = <counterExample>
};
var result = _conversation.CreateCounterexample(<workspaceId>, example);
Delete a counterexample from a workspace. Counterexamples are examples that have been marked as irrelevant input.
var result = _conversation.DeleteCounterexample(<workspaceId>, <counterExample>);
Get information about a counterexample. Counterexamples are examples that have been marked as irrelevant input.
var result = _conversation.GetCounterexample(<workspaceId>, <counterExample>);
Update the text of a counterexample. Counterexamples are examples that have been marked as irrelevant input.
UpdateExample updatedExample = new UpdateExample()
{
Text = <updatedCounterExample>
};
var result = _conversation.UpdateCounterexample(<workspaceId>, <counterExample>, updatedExample);
List the entities for a workspace.
var result = _conversation.ListEntities(<workspaceId>);
Create a new entity.
CreateEntity entity = new CreateEntity()
{
Entity = <entity>,
Description = <entity-description>
};
var result = _conversation.CreateEntity(<workspaceId>, entity);
Delete an entity from a workspace.
var result = _conversation.DeleteEntity(<workspaceId>, <entity>);
Get information about an entity, optionally including all entity content.
var result = _conversation.GetEntity(<workspaceId>, <entity>);
Update an existing entity with new or modified data. You must provide JSON data defining the content of the updated entity.
Any elements included in the new JSON will completely replace the equivalent existing elements, including all subelements. (Previously existing subelements are not retained unless they are included in the new JSON.) For example, if you update the values for an entity, the previously existing values are discarded and replaced with the new values specified in the JSON input.
UpdateEntity updatedEntity = new UpdateEntity()
{
Entity = updatedEntity,
Description = updatedEntityDescription
};
var result = _conversation.UpdateEntity(<workspaceId>, <entity>, updatedEntity);
List the values for an entity.
var result = _conversation.ListValues(<workspaceId>, <entity>);
Add a new value to an entity.
CreateValue value = new CreateValue()
{
Value = <value>
};
var result = _conversation.CreateValue(<workspaceId>, <entity>, value);
Delete a value from an entity.
var result = _conversation.DeleteValue(<workspaceId>, <entity>, <value>);
Get information about an entity value.
var result = _conversation.GetValue(<workspaceId>, <entity>, <value>);
Update an existing entity value with new or modified data. You must provide JSON data defining the content of the updated entity value.
Any elements included in the new JSON will completely replace the equivalent existing elements, including all subelements. (Previously existing subelements are not retained unless they are included in the new JSON.) For example, if you update the synonyms for an entity value, the previously existing synonyms are discarded and replaced with the new synonyms specified in the JSON input.
UpdateValue updatedValue = new UpdateValue()
{
Value = <updatedValue>
};
var result = _conversation.UpdateValue(<workspaceId>, <entity>, <value>, updatedValue);
List the synonyms for an entity value.
var result = _conversation.ListSynonyms(<workspaceId>, <entity>, <value>);
Add a new synonym to an entity value.
CreateSynonym synonym = new CreateSynonym()
{
Synonym = <synonym>
};
var result = _conversation.CreateSynonym(<workspaceId>, <entity>, <value>, synonym);
Delete a synonym from an entity value.
var result = _conversation.DeleteSynonym(<workspaceId>, <entity>, <value>, <synonym>);
Get information about a synonym of an entity value.
var result = _conversation.GetSynonym(<workspaceId>, <entity>, <value>, <synonym>);
Update an existing entity value synonym with new text.
UpdateSynonym updatedSynonym = new UpdateSynonym()
{
Synonym = <synonym>
};
var result = _conversation.UpdateSynonym(<workspaceId>, <entity>, <value>, <synonym>, updatedSynonym);
List the intents for a workspace.
var result = _conversation.ListIntents(<workspaceId>);
Create a new intent.
CreateIntent intent = new CreateIntent()
{
Intent = <intent>,
Description = <intent-description>
};
var result = _conversation.CreateIntent(<workspaceId>, intent);
Delete an intent from a workspace.
var result = _conversation.DeleteIntent(<workspaceId>, <intent>);
Get information about an intent, optionally including all intent content.
var result = _conversation.GetIntent(<workspaceId>, <intent>);
Update an existing intent with new or modified data. You must provide JSON data defining the content of the updated intent.
Any elements included in the new JSON will completely replace the equivalent existing elements, including all subelements. (Previously existing subelements are not retained unless they are included in the new JSON.) For example, if you update the user input examples for an intent, the previously existing examples are discarded and replaced with the new examples specified in the JSON input.
UpdateIntent intent = new UpdateIntent()
{
Intent = <intent>,
Description = <intent-description>
};
var result = _conversation.UpdateIntent(<workspaceId>, <intent>, intent);
List the user input examples for an intent.
var result = _conversation.ListExamples(<workspaceId>, <intent>);
Add a new user input example to an intent.
CreateExample example = new CreateExample()
{
Text = <example>
};
var result = _conversation.CreateExample(<workspaceId>, <intent>, example);
Delete a user input example from an intent.
var result = _conversation.DeleteExample(<workspaceId>, <intent>, <example>);
Get information about a user input example.
var result = _conversation.GetExample(<workspaceId>, <intent>, <example>);
Update the text of a user input example.
UpdateExample updatedExample = new UpdateExample()
{
Text = <example>
};
var result = _conversation.UpdateExample(<workspaceId>, <intent>, <example>, updatedExample);
List the events from the log of a workspace.
var result = _conversation.ListLogs(<workspaceId>);