|
| 1 | +# Assistant V2 |
| 2 | + |
| 3 | +The IBM Watson™ [Assistant][assistant] service combines machine learning, natural language understanding, and integrated dialog tools to create conversation flows between your apps and your users. |
| 4 | + |
| 5 | +## Usage |
| 6 | +You complete these steps to implement your application: |
| 7 | + |
| 8 | +* Create an assistant. |
| 9 | + |
| 10 | +* Add skills to your assistant. Choose the appropriate skill set for each assistant that you want to build. |
| 11 | + |
| 12 | + Note: Currently, you can add one conversational skill to the assistant. |
| 13 | + |
| 14 | +* Configure the skill. For a conversational skill, use the intuitive graphical tool to define the training data and dialog for the conversation between your assistant and your customers. |
| 15 | + |
| 16 | + The training data consists of the following artifacts: |
| 17 | + |
| 18 | + * Intents: Goals that you anticipate your users will have when they interact with the service. Define one intent for each goal that can be identified in a user's input. For example, you might define an intent named store_hours that answers questions about store hours. For each intent, you add sample utterances that reflect the input customers might use to ask for the information they need, such as, What time do you open? |
| 19 | + |
| 20 | + Or use prebuilt content catalogs provided by IBM to get started with data that addresses common customer goals. |
| 21 | + |
| 22 | + * Entities: An entity represents a term or object that provides context for an intent. For example, an entity might be a city name that helps your dialog to distinguish which store the user wants to know store hours for. |
| 23 | + |
| 24 | + As you add training data, a natural language classifier is automatically added to the skill, and is trained to understand the types of requests that you have indicated the service should listen for and respond to. |
| 25 | + |
| 26 | + * Dialog: Use the dialog tool to build a dialog flow that incorporates your intents and entities. The dialog flow is represented graphically in the tool as a tree. You can add a branch to process each of the intents that you want the service to handle. You can then add branch nodes that handle the many possible permutations of a request based on other factors, such as the entities found in the user input or information that is passed to the service from an external service. |
| 27 | + |
| 28 | +* Integrate your assistant. Create a channel integration to deploy the configured assistant directly to a social media or messaging channel. |
| 29 | + |
| 30 | +#### Create session |
| 31 | +Create a new session. A session is used to send user input to a skill and receive responses. It also maintains the state of the conversation. |
| 32 | +```cs |
| 33 | +private void Example() |
| 34 | +{ |
| 35 | + _assistant.CreateSession(OnCreateSession, OnFail, assistantId); |
| 36 | +} |
| 37 | + |
| 38 | +private void OnCreateSession(SessionResponse response, Dictionary<string, object> customData) |
| 39 | +{ |
| 40 | + Log.Debug("ExampleAssistantV2.OnMessage()", "Assistant: Create Session Response: {0}", customData["json"].ToString()); |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +#### Delete Session |
| 45 | +Deletes a session explicitly before it times out. |
| 46 | +```cs |
| 47 | +private void Example() |
| 48 | +{ |
| 49 | + _assistant.DeleteSession(OnDeleteSession, OnFail, assistantId, sessionId); |
| 50 | +} |
| 51 | + |
| 52 | +private void OnDeleteSession(object response, Dictionary<string, object> customData) |
| 53 | +{ |
| 54 | + Log.Debug("ExampleAssistantV2.OnMessage()", "Assistant: Delete Session Response: {0}", customData["json"].ToString()); |
| 55 | +} |
| 56 | +``` |
| 57 | + |
| 58 | +#### Message |
| 59 | +Send user input to an assistant and receive a response. There is no rate limit for this operation. |
| 60 | +```cs |
| 61 | +private void Example() |
| 62 | +{ |
| 63 | + MessageRequest messageRequest = new MessageRequest() |
| 64 | + { |
| 65 | + Input = new MessageInput() |
| 66 | + { |
| 67 | + Text = "conversation text" |
| 68 | + } |
| 69 | + }; |
| 70 | + |
| 71 | + _assistant.Message(OnMessage, OnFail, assistantId, sessionId, messageRequest); |
| 72 | +} |
| 73 | + |
| 74 | +private void OnMessage(MessageResponse response, Dictionary<string, object> customData) |
| 75 | +{ |
| 76 | + Log.Debug("ExampleAssistantV2.OnMessage()", "Assistant: Message Response: {0}", customData["json"].ToString()); |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | + |
| 81 | +[assistant]: https://console.bluemix.net/docs/services/assistant/index.html |
0 commit comments