|
| 1 | +[](https://www.nuget.org/packages/IBM.WatsonDeveloperCloud.Conversation.v1/) |
| 2 | + |
| 3 | +### Conversation |
| 4 | + |
| 5 | +With the IBM Watson™ [Conversation][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. |
| 6 | + |
| 7 | +### Installation |
| 8 | +#### Nuget |
| 9 | +``` |
| 10 | +
|
| 11 | +PM > Install-Package IBM.WatsonDeveloperCloud.Conversation.v1 |
| 12 | +
|
| 13 | +``` |
| 14 | +#### Project.json |
| 15 | +```JSON |
| 16 | + |
| 17 | +"dependencies": { |
| 18 | + "IBM.WatsonDeveloperCloud.Conversation.v1": "1.2.0" |
| 19 | +} |
| 20 | + |
| 21 | +``` |
| 22 | +### Usage |
| 23 | +You complete these steps to implement your application: |
| 24 | + |
| 25 | +* Configure a workspace. With the easy-to-use graphical environment, you set up the dialog flow and training data for your application. |
| 26 | + |
| 27 | +* 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. |
| 28 | + |
| 29 | +#### Instantiating and authenticating the service |
| 30 | +Before you can send requests to the service it must be instantiated and credentials must be set. |
| 31 | +```cs |
| 32 | +// create a Conversation Service instance |
| 33 | +ConversationService _conversation = new ConversationService(); |
| 34 | + |
| 35 | +// set the credentials |
| 36 | +_conversation.SetCredential(<username>, <password>); |
| 37 | +``` |
| 38 | + |
| 39 | +#### List workspaces |
| 40 | +List existing workspaces for the service instance. |
| 41 | +```cs |
| 42 | +var result = _conversation.ListWorkspaces(); |
| 43 | +``` |
| 44 | + |
| 45 | +#### Create workspace |
| 46 | +Create a new workspace. |
| 47 | +```cs |
| 48 | +CreateWorkspace workspace = new CreateWorkspace() |
| 49 | +{ |
| 50 | + Name = <workspace-name>, |
| 51 | + Description = <workspace-description>, |
| 52 | + Language = <workspace-language> |
| 53 | +}; |
| 54 | + |
| 55 | +var result = _conversation.CreateWorkspace(workspace); |
| 56 | +``` |
| 57 | + |
| 58 | +#### Delete workspace |
| 59 | +Delete an existing workspace. |
| 60 | +```cs |
| 61 | +var result = _conversation.DeleteWorkspace(<workspace-id>); |
| 62 | +``` |
| 63 | + |
| 64 | +#### Get workspace details |
| 65 | +Get detailed information about a specific workspace. |
| 66 | +```cs |
| 67 | +var result = _conversation.GetWorkspace(<workspace-id>); |
| 68 | +``` |
| 69 | + |
| 70 | +#### Update workspace details |
| 71 | +Update an existing workspace. |
| 72 | +```cs |
| 73 | +UpdateWorkspace updatedWorkspace = new UpdateWorkspace() |
| 74 | +{ |
| 75 | + Name = <updated-workspace-name>, |
| 76 | + Description = <updated-workspace-description>, |
| 77 | + Language = <updated-workspace-language> |
| 78 | +}; |
| 79 | + |
| 80 | +var result = _conversation.UpdateWorkspace(<workspace-id>, updatedWorkspace); |
| 81 | +``` |
| 82 | + |
| 83 | +#### Message |
| 84 | +Get a response to a user's input. |
| 85 | +```cs |
| 86 | +// create message request |
| 87 | +MessageRequest messageRequest0 = new MessageRequest() |
| 88 | +{ |
| 89 | + Input = new InputData() |
| 90 | + { |
| 91 | + Text = <input-string0> |
| 92 | + } |
| 93 | +}; |
| 94 | + |
| 95 | +// send a message to the conversation instance |
| 96 | +var result0 = _conversation.Message(<workspace-id>, messageRequest0); |
| 97 | + |
| 98 | +// reference the message context to continue a conversation |
| 99 | +messageRequest messageRequest1 = new MessageRequest() |
| 100 | +{ |
| 101 | + Input = new InputData() |
| 102 | + { |
| 103 | + Text = <input-string1> |
| 104 | + }, |
| 105 | + Context = result.Context |
| 106 | +}; |
| 107 | + |
| 108 | +// Send another message including message context. |
| 109 | +result1 = _conversation.Message(<workspace-id>, messageRequest1); |
| 110 | +``` |
| 111 | + |
| 112 | +#### List Counterexamples |
| 113 | +List the counterexamples for a workspace. Counterexamples are examples that have been marked as irrelevant input. |
| 114 | +```cs |
| 115 | +var result = _conversation.ListCounterexamples(<workspaceId>); |
| 116 | +``` |
| 117 | + |
| 118 | +#### Create Counterexamples |
| 119 | +Add a new counterexample to a workspace. Counterexamples are examples that have been marked as irrelevant input. |
| 120 | +```cs |
| 121 | +CreateExample example = new CreateExample() |
| 122 | +{ |
| 123 | + Text = <counterExample> |
| 124 | +}; |
| 125 | + |
| 126 | +var result = _conversation.CreateCounterexample(<workspaceId>, example); |
| 127 | +``` |
| 128 | + |
| 129 | +#### Delete Counterexample |
| 130 | +Delete a counterexample from a workspace. Counterexamples are examples that have been marked as irrelevant input. |
| 131 | +```cs |
| 132 | +var result = _conversation.DeleteCounterexample(<workspaceId>, <counterExample>); |
| 133 | +``` |
| 134 | + |
| 135 | +#### Get Counterexample |
| 136 | +Get information about a counterexample. Counterexamples are examples that have been marked as irrelevant input. |
| 137 | +```cs |
| 138 | +var result = _conversation.GetCounterexample(<workspaceId>, <counterExample>); |
| 139 | +``` |
| 140 | + |
| 141 | +#### Update Counterexample |
| 142 | +Update the text of a counterexample. Counterexamples are examples that have been marked as irrelevant input. |
| 143 | +```cs |
| 144 | +UpdateExample updatedExample = new UpdateExample() |
| 145 | +{ |
| 146 | + Text = <updatedCounterExample> |
| 147 | +}; |
| 148 | + |
| 149 | +var result = _conversation.UpdateCounterexample(<workspaceId>, <counterExample>, updatedExample); |
| 150 | +``` |
| 151 | + |
| 152 | +#### List Entities |
| 153 | +List the entities for a workspace. |
| 154 | +```cs |
| 155 | +var result = _conversation.ListEntities(<workspaceId>); |
| 156 | +``` |
| 157 | + |
| 158 | +#### Create Entity |
| 159 | +Create a new entity. |
| 160 | +```cs |
| 161 | +CreateEntity entity = new CreateEntity() |
| 162 | +{ |
| 163 | + Entity = <entity>, |
| 164 | + Description = <entity-description> |
| 165 | +}; |
| 166 | + |
| 167 | +var result = _conversation.CreateEntity(<workspaceId>, entity); |
| 168 | +``` |
| 169 | + |
| 170 | +#### Delete Entity |
| 171 | +Delete an entity from a workspace. |
| 172 | +```cs |
| 173 | +var result = _conversation.DeleteEntity(<workspaceId>, <entity>); |
| 174 | +``` |
| 175 | + |
| 176 | +#### Get Entity |
| 177 | +Get information about an entity, optionally including all entity content. |
| 178 | +```cs |
| 179 | +var result = _conversation.GetEntity(<workspaceId>, <entity>); |
| 180 | +``` |
| 181 | + |
| 182 | +#### Update Entity |
| 183 | +Update an existing entity with new or modified data. You must provide JSON data defining the content of the updated entity. |
| 184 | + |
| 185 | +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. |
| 186 | +```cs |
| 187 | +UpdateEntity updatedEntity = new UpdateEntity() |
| 188 | +{ |
| 189 | + Entity = updatedEntity, |
| 190 | + Description = updatedEntityDescription |
| 191 | +}; |
| 192 | + |
| 193 | +var result = _conversation.UpdateEntity(<workspaceId>, <entity>, updatedEntity); |
| 194 | +``` |
| 195 | + |
| 196 | +#### List Entity Values |
| 197 | +List the values for an entity. |
| 198 | +```cs |
| 199 | +var result = _conversation.ListValues(<workspaceId>, <entity>); |
| 200 | +``` |
| 201 | + |
| 202 | +#### Add Entity Value |
| 203 | +Add a new value to an entity. |
| 204 | +```cs |
| 205 | +CreateValue value = new CreateValue() |
| 206 | +{ |
| 207 | + Value = <value> |
| 208 | +}; |
| 209 | + |
| 210 | +var result = _conversation.CreateValue(<workspaceId>, <entity>, value); |
| 211 | +``` |
| 212 | + |
| 213 | +#### Delete Entity Value |
| 214 | +Delete a value from an entity. |
| 215 | +```cs |
| 216 | +var result = _conversation.DeleteValue(<workspaceId>, <entity>, <value>); |
| 217 | +``` |
| 218 | + |
| 219 | +#### Get Entity Value |
| 220 | +Get information about an entity value. |
| 221 | +```cs |
| 222 | +var result = _conversation.GetValue(<workspaceId>, <entity>, <value>); |
| 223 | +``` |
| 224 | + |
| 225 | +#### Update Entity Value |
| 226 | +Update an existing entity value with new or modified data. You must provide JSON data defining the content of the updated entity value. |
| 227 | + |
| 228 | +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. |
| 229 | +```cs |
| 230 | +UpdateValue updatedValue = new UpdateValue() |
| 231 | +{ |
| 232 | + Value = <updatedValue> |
| 233 | +}; |
| 234 | + |
| 235 | +var result = _conversation.UpdateValue(<workspaceId>, <entity>, <value>, updatedValue); |
| 236 | +``` |
| 237 | + |
| 238 | +#### List Synonyms |
| 239 | +List the synonyms for an entity value. |
| 240 | +```cs |
| 241 | +var result = _conversation.ListSynonyms(<workspaceId>, <entity>, <value>); |
| 242 | +``` |
| 243 | + |
| 244 | +#### Add Synonym |
| 245 | +Add a new synonym to an entity value. |
| 246 | +```cs |
| 247 | +CreateSynonym synonym = new CreateSynonym() |
| 248 | +{ |
| 249 | + Synonym = <synonym> |
| 250 | +}; |
| 251 | + |
| 252 | +var result = _conversation.CreateSynonym(<workspaceId>, <entity>, <value>, synonym); |
| 253 | +``` |
| 254 | + |
| 255 | +#### Delete Synonym |
| 256 | +Delete a synonym from an entity value. |
| 257 | +```cs |
| 258 | +var result = _conversation.DeleteSynonym(<workspaceId>, <entity>, <value>, <synonym>); |
| 259 | +``` |
| 260 | + |
| 261 | +#### Get Synonym |
| 262 | +Get information about a synonym of an entity value. |
| 263 | +```cs |
| 264 | +var result = _conversation.GetSynonym(<workspaceId>, <entity>, <value>, <synonym>); |
| 265 | +``` |
| 266 | + |
| 267 | +#### Update Synonym |
| 268 | +Update an existing entity value synonym with new text. |
| 269 | +```cs |
| 270 | +UpdateSynonym updatedSynonym = new UpdateSynonym() |
| 271 | +{ |
| 272 | + Synonym = <synonym> |
| 273 | +}; |
| 274 | + |
| 275 | +var result = _conversation.UpdateSynonym(<workspaceId>, <entity>, <value>, <synonym>, updatedSynonym); |
| 276 | +``` |
| 277 | + |
| 278 | +#### List Intents |
| 279 | +List the intents for a workspace. |
| 280 | +```cs |
| 281 | +var result = _conversation.ListIntents(<workspaceId>); |
| 282 | +``` |
| 283 | + |
| 284 | +#### Create Intent |
| 285 | +Create a new intent. |
| 286 | +```cs |
| 287 | +CreateIntent intent = new CreateIntent() |
| 288 | +{ |
| 289 | + Intent = <intent>, |
| 290 | + Description = <intent-description> |
| 291 | +}; |
| 292 | + |
| 293 | +var result = _conversation.CreateIntent(<workspaceId>, intent); |
| 294 | +``` |
| 295 | + |
| 296 | +#### Delete Intent |
| 297 | +Delete an intent from a workspace. |
| 298 | +```cs |
| 299 | +var result = _conversation.DeleteIntent(<workspaceId>, <intent>); |
| 300 | +``` |
| 301 | + |
| 302 | +#### Get Intent |
| 303 | +Get information about an intent, optionally including all intent content. |
| 304 | +```cs |
| 305 | +var result = _conversation.GetIntent(<workspaceId>, <intent>); |
| 306 | +``` |
| 307 | + |
| 308 | +#### Update Intent |
| 309 | +Update an existing intent with new or modified data. You must provide JSON data defining the content of the updated intent. |
| 310 | + |
| 311 | +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. |
| 312 | +```cs |
| 313 | +UpdateIntent intent = new UpdateIntent() |
| 314 | +{ |
| 315 | + Intent = <intent>, |
| 316 | + Description = <intent-description> |
| 317 | +}; |
| 318 | + |
| 319 | +var result = _conversation.UpdateIntent(<workspaceId>, <intent>, intent); |
| 320 | +``` |
| 321 | + |
| 322 | +#### List Examples |
| 323 | +List the user input examples for an intent. |
| 324 | +```cs |
| 325 | +var result = _conversation.ListExamples(<workspaceId>, <intent>); |
| 326 | +``` |
| 327 | + |
| 328 | +#### Create Example |
| 329 | +Add a new user input example to an intent. |
| 330 | +```cs |
| 331 | +CreateExample example = new CreateExample() |
| 332 | +{ |
| 333 | + Text = <example> |
| 334 | +}; |
| 335 | + |
| 336 | +var result = _conversation.CreateExample(<workspaceId>, <intent>, example); |
| 337 | +``` |
| 338 | + |
| 339 | +#### Delete Example |
| 340 | +Delete a user input example from an intent. |
| 341 | +```cs |
| 342 | +var result = _conversation.DeleteExample(<workspaceId>, <intent>, <example>); |
| 343 | +``` |
| 344 | + |
| 345 | +#### Get Example |
| 346 | +Get information about a user input example. |
| 347 | +```cs |
| 348 | +var result = _conversation.GetExample(<workspaceId>, <intent>, <example>); |
| 349 | +``` |
| 350 | + |
| 351 | +#### Update Example |
| 352 | +Update the text of a user input example. |
| 353 | +```cs |
| 354 | +UpdateExample updatedExample = new UpdateExample() |
| 355 | +{ |
| 356 | + Text = <example> |
| 357 | +}; |
| 358 | + |
| 359 | +var result = _conversation.UpdateExample(<workspaceId>, <intent>, <example>, updatedExample); |
| 360 | +``` |
| 361 | + |
| 362 | +#### List Log Events |
| 363 | +List the events from the log of a workspace. |
| 364 | +```cs |
| 365 | +var result = _conversation.ListLogs(<workspaceId>); |
| 366 | +``` |
| 367 | + |
| 368 | +[conversation]:https://console.bluemix.net/docs/services/conversation/index.html#about |
0 commit comments