Documentation
¶
Overview ¶
Package assistantv2 : Operations and models for the AssistantV2 service
Index ¶
- Constants
- type AssistantV2
- func (assistant *AssistantV2) CreateSession(createSessionOptions *CreateSessionOptions) (*core.DetailedResponse, error)
- func (assistant *AssistantV2) DeleteSession(deleteSessionOptions *DeleteSessionOptions) (*core.DetailedResponse, error)
- func (assistant *AssistantV2) GetCreateSessionResult(response *core.DetailedResponse) *SessionResponse
- func (assistant *AssistantV2) GetMessageResult(response *core.DetailedResponse) *MessageResponse
- func (assistant *AssistantV2) Message(messageOptions *MessageOptions) (*core.DetailedResponse, error)
- func (assistant *AssistantV2) NewCreateSessionOptions(assistantID string) *CreateSessionOptions
- func (assistant *AssistantV2) NewDeleteSessionOptions(assistantID string, sessionID string) *DeleteSessionOptions
- func (assistant *AssistantV2) NewMessageOptions(assistantID string, sessionID string) *MessageOptions
- type AssistantV2Options
- type CaptureGroup
- type CreateSessionOptions
- type DeleteSessionOptions
- type DialogLogMessage
- type DialogNodeAction
- type DialogNodeOutputOptionsElement
- type DialogNodeOutputOptionsElementValue
- type DialogNodesVisited
- type DialogRuntimeResponseGeneric
- type DialogSuggestion
- type DialogSuggestionValue
- type MessageContext
- type MessageContextGlobal
- type MessageContextGlobalSystem
- type MessageContextSkills
- type MessageInput
- type MessageInputOptions
- type MessageOptions
- func (options *MessageOptions) SetAssistantID(assistantID string) *MessageOptions
- func (options *MessageOptions) SetContext(context *MessageContext) *MessageOptions
- func (options *MessageOptions) SetHeaders(param map[string]string) *MessageOptions
- func (options *MessageOptions) SetInput(input *MessageInput) *MessageOptions
- func (options *MessageOptions) SetSessionID(sessionID string) *MessageOptions
- type MessageOutput
- type MessageOutputDebug
- type MessageResponse
- type RuntimeEntity
- type RuntimeIntent
- type SessionResponse
Constants ¶
const ( DialogLogMessage_Level_Error = "error" DialogLogMessage_Level_Info = "info" DialogLogMessage_Level_Warn = "warn" )
Constants associated with the DialogLogMessage.Level property. The severity of the log message.
const ( DialogNodeAction_ActionType_Client = "client" DialogNodeAction_ActionType_Server = "server" )
Constants associated with the DialogNodeAction.ActionType property. The type of action to invoke.
const ( DialogRuntimeResponseGeneric_ResponseType_ConnectToAgent = "connect_to_agent" DialogRuntimeResponseGeneric_ResponseType_Image = "image" DialogRuntimeResponseGeneric_ResponseType_Option = "option" DialogRuntimeResponseGeneric_ResponseType_Pause = "pause" DialogRuntimeResponseGeneric_ResponseType_Suggestion = "suggestion" DialogRuntimeResponseGeneric_ResponseType_Text = "text" )
Constants associated with the DialogRuntimeResponseGeneric.ResponseType property. The type of response returned by the dialog node. The specified response type must be supported by the client application or channel.
**Note:** The **suggestion** response type is part of the disambiguation feature, which is only available for Premium users.
const ( DialogRuntimeResponseGeneric_Preference_Button = "button" DialogRuntimeResponseGeneric_Preference_Dropdown = "dropdown" )
Constants associated with the DialogRuntimeResponseGeneric.Preference property. The preferred type of control to display.
const ( MessageOutputDebug_BranchExitedReason_Completed = "completed" MessageOutputDebug_BranchExitedReason_Fallback = "fallback" )
Constants associated with the MessageOutputDebug.BranchExitedReason property. When `branch_exited` is set to `true` by the Assistant, the `branch_exited_reason` specifies whether the dialog completed by itself or got interrupted.
const (
MessageInput_MessageType_Text = "text"
)
Constants associated with the MessageInput.MessageType property. The type of user input. Currently, only text input is supported.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssistantV2 ¶
type AssistantV2 struct {
Service *core.WatsonService
}
AssistantV2 : The IBM Watson™ Assistant service combines machine learning, natural language understanding, and integrated dialog tools to create conversation flows between your apps and your users.
Version: V2 See: http://www.ibm.com/watson/developercloud/assistant.html
func NewAssistantV2 ¶
func NewAssistantV2(options *AssistantV2Options) (*AssistantV2, error)
NewAssistantV2 : Instantiate AssistantV2
func (*AssistantV2) CreateSession ¶
func (assistant *AssistantV2) CreateSession(createSessionOptions *CreateSessionOptions) (*core.DetailedResponse, error)
CreateSession : Create a session 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.
func (*AssistantV2) DeleteSession ¶
func (assistant *AssistantV2) DeleteSession(deleteSessionOptions *DeleteSessionOptions) (*core.DetailedResponse, error)
DeleteSession : Delete session Deletes a session explicitly before it times out.
func (*AssistantV2) GetCreateSessionResult ¶
func (assistant *AssistantV2) GetCreateSessionResult(response *core.DetailedResponse) *SessionResponse
GetCreateSessionResult : Retrieve result of CreateSession operation
func (*AssistantV2) GetMessageResult ¶
func (assistant *AssistantV2) GetMessageResult(response *core.DetailedResponse) *MessageResponse
GetMessageResult : Retrieve result of Message operation
func (*AssistantV2) Message ¶
func (assistant *AssistantV2) Message(messageOptions *MessageOptions) (*core.DetailedResponse, error)
Message : Send user input to assistant Send user input to an assistant and receive a response.
There is no rate limit for this operation.
func (*AssistantV2) NewCreateSessionOptions ¶
func (assistant *AssistantV2) NewCreateSessionOptions(assistantID string) *CreateSessionOptions
NewCreateSessionOptions : Instantiate CreateSessionOptions
func (*AssistantV2) NewDeleteSessionOptions ¶
func (assistant *AssistantV2) NewDeleteSessionOptions(assistantID string, sessionID string) *DeleteSessionOptions
NewDeleteSessionOptions : Instantiate DeleteSessionOptions
func (*AssistantV2) NewMessageOptions ¶
func (assistant *AssistantV2) NewMessageOptions(assistantID string, sessionID string) *MessageOptions
NewMessageOptions : Instantiate MessageOptions
type AssistantV2Options ¶
type AssistantV2Options struct {
Version string
URL string
Username string
Password string
IAMApiKey string
IAMAccessToken string
IAMURL string
}
AssistantV2Options : Service options
type CaptureGroup ¶
type CaptureGroup struct {
// A recognized capture group for the entity.
Group *string `json:"group" validate:"required"`
// Zero-based character offsets that indicate where the entity value begins and ends in the input text.
Location []int64 `json:"location,omitempty"`
}
CaptureGroup : CaptureGroup struct
type CreateSessionOptions ¶
type CreateSessionOptions struct {
// Unique identifier of the assistant. You can find the assistant ID of an assistant on the **Assistants** tab of the
// Watson Assistant tool. For information about creating assistants, see the
// [documentation](https://console.bluemix.net/docs/services/assistant/create-assistant.html#creating-assistants).
//
// **Note:** Currently, the v2 API does not support creating assistants.
AssistantID *string `json:"assistant_id" validate:"required"`
// Allows users to set headers to be GDPR compliant
Headers map[string]string
}
CreateSessionOptions : The createSession options.
func (*CreateSessionOptions) SetAssistantID ¶
func (options *CreateSessionOptions) SetAssistantID(assistantID string) *CreateSessionOptions
SetAssistantID : Allow user to set AssistantID
func (*CreateSessionOptions) SetHeaders ¶
func (options *CreateSessionOptions) SetHeaders(param map[string]string) *CreateSessionOptions
SetHeaders : Allow user to set Headers
type DeleteSessionOptions ¶
type DeleteSessionOptions struct {
// Unique identifier of the assistant. You can find the assistant ID of an assistant on the **Assistants** tab of the
// Watson Assistant tool. For information about creating assistants, see the
// [documentation](https://console.bluemix.net/docs/services/assistant/create-assistant.html#creating-assistants).
//
// **Note:** Currently, the v2 API does not support creating assistants.
AssistantID *string `json:"assistant_id" validate:"required"`
// Unique identifier of the session.
SessionID *string `json:"session_id" validate:"required"`
// Allows users to set headers to be GDPR compliant
Headers map[string]string
}
DeleteSessionOptions : The deleteSession options.
func (*DeleteSessionOptions) SetAssistantID ¶
func (options *DeleteSessionOptions) SetAssistantID(assistantID string) *DeleteSessionOptions
SetAssistantID : Allow user to set AssistantID
func (*DeleteSessionOptions) SetHeaders ¶
func (options *DeleteSessionOptions) SetHeaders(param map[string]string) *DeleteSessionOptions
SetHeaders : Allow user to set Headers
func (*DeleteSessionOptions) SetSessionID ¶
func (options *DeleteSessionOptions) SetSessionID(sessionID string) *DeleteSessionOptions
SetSessionID : Allow user to set SessionID
type DialogLogMessage ¶
type DialogLogMessage struct {
// The severity of the log message.
Level *string `json:"level" validate:"required"`
// The text of the log message.
Message *string `json:"message" validate:"required"`
}
DialogLogMessage : Dialog log message details.
type DialogNodeAction ¶
type DialogNodeAction struct {
// The name of the action.
Name *string `json:"name" validate:"required"`
// The type of action to invoke.
ActionType *string `json:"type,omitempty"`
// A map of key/value pairs to be provided to the action.
Parameters interface{} `json:"parameters,omitempty"`
// The location in the dialog context where the result of the action is stored.
ResultVariable *string `json:"result_variable" validate:"required"`
// The name of the context variable that the client application will use to pass in credentials for the action.
Credentials *string `json:"credentials,omitempty"`
}
DialogNodeAction : DialogNodeAction struct
type DialogNodeOutputOptionsElement ¶
type DialogNodeOutputOptionsElement struct {
// The user-facing label for the option.
Label *string `json:"label" validate:"required"`
// An object defining the message input to be sent to the assistant if the user selects the corresponding option.
Value *DialogNodeOutputOptionsElementValue `json:"value" validate:"required"`
}
DialogNodeOutputOptionsElement : DialogNodeOutputOptionsElement struct
type DialogNodeOutputOptionsElementValue ¶
type DialogNodeOutputOptionsElementValue struct {
// The user input.
Input *MessageInput `json:"input,omitempty"`
}
DialogNodeOutputOptionsElementValue : An object defining the message input to be sent to the assistant if the user selects the corresponding option.
type DialogNodesVisited ¶
type DialogNodesVisited struct {
// A dialog node that was triggered during processing of the input message.
DialogNode *string `json:"dialog_node,omitempty"`
// The title of the dialog node.
Title *string `json:"title,omitempty"`
// The conditions that trigger the dialog node.
Conditions *string `json:"conditions,omitempty"`
}
DialogNodesVisited : DialogNodesVisited struct
type DialogRuntimeResponseGeneric ¶
type DialogRuntimeResponseGeneric struct {
// The type of response returned by the dialog node. The specified response type must be supported by the client
// application or channel.
//
// **Note:** The **suggestion** response type is part of the disambiguation feature, which is only available for
// Premium users.
ResponseType *string `json:"response_type" validate:"required"`
// The text of the response.
Text *string `json:"text,omitempty"`
// How long to pause, in milliseconds.
Time *int64 `json:"time,omitempty"`
// Whether to send a "user is typing" event during the pause.
Typing *bool `json:"typing,omitempty"`
// The URL of the image.
Source *string `json:"source,omitempty"`
// The title to show before the response.
Title *string `json:"title,omitempty"`
// The description to show with the the response.
Description *string `json:"description,omitempty"`
// The preferred type of control to display.
Preference *string `json:"preference,omitempty"`
// An array of objects describing the options from which the user can choose.
Options []DialogNodeOutputOptionsElement `json:"options,omitempty"`
// A message to be sent to the human agent who will be taking over the conversation.
MessageToHumanAgent *string `json:"message_to_human_agent,omitempty"`
// A label identifying the topic of the conversation, derived from the **user_label** property of the relevant node.
Topic *string `json:"topic,omitempty"`
// An array of objects describing the possible matching dialog nodes from which the user can choose.
//
// **Note:** The **suggestions** property is part of the disambiguation feature, which is only available for Premium
// users.
Suggestions []DialogSuggestion `json:"suggestions,omitempty"`
}
DialogRuntimeResponseGeneric : DialogRuntimeResponseGeneric struct
type DialogSuggestion ¶
type DialogSuggestion struct {
// The user-facing label for the disambiguation option. This label is taken from the **user_label** property of the
// corresponding dialog node.
Label *string `json:"label" validate:"required"`
// An object defining the message input to be sent to the assistant if the user selects the corresponding
// disambiguation option.
Value *DialogSuggestionValue `json:"value" validate:"required"`
// The dialog output that will be returned from the Watson Assistant service if the user selects the corresponding
// option.
Output interface{} `json:"output,omitempty"`
}
DialogSuggestion : DialogSuggestion struct
type DialogSuggestionValue ¶
type DialogSuggestionValue struct {
// The user input.
Input *MessageInput `json:"input,omitempty"`
}
DialogSuggestionValue : An object defining the message input to be sent to the assistant if the user selects the corresponding disambiguation option.
type MessageContext ¶
type MessageContext struct {
// Contains information that can be shared by all skills within the Assistant.
Global *MessageContextGlobal `json:"global,omitempty"`
// Contains information specific to particular skills within the Assistant.
Skills *MessageContextSkills `json:"skills,omitempty"`
}
MessageContext : State information for the conversation.
type MessageContextGlobal ¶
type MessageContextGlobal struct {
// Properties interpreted by the Assistant that are shared across all skills within the Assistant.
System *MessageContextGlobalSystem `json:"system,omitempty"`
}
MessageContextGlobal : Contains information that can be shared by all skills within the Assistant.
type MessageContextGlobalSystem ¶
type MessageContextGlobalSystem struct {
// The user time zone. The assistant uses the time zone to correctly resolve relative time references.
Timezone *string `json:"timezone,omitempty"`
// A string value that identifies the user who is interacting with the assistant. The client must provide a unique
// identifier for each individual end user who accesses the application. This user ID may be used for billing and other
// purposes.
UserID *string `json:"user_id,omitempty"`
// A counter that is automatically incremented with each turn of the conversation. A value of 1 indicates that this is
// the the first turn of a new conversation, which can affect the behavior of some skills.
TurnCount *int64 `json:"turn_count,omitempty"`
}
MessageContextGlobalSystem : Properties that are shared by all skills used by the assistant.
type MessageContextSkills ¶
type MessageContextSkills struct {
}
MessageContextSkills : Contains information specific to particular skills within the Assistant.
type MessageInput ¶
type MessageInput struct {
// The type of user input. Currently, only text input is supported.
MessageType *string `json:"message_type,omitempty"`
// The text of the user input. This string cannot contain carriage return, newline, or tab characters, and it must be
// no longer than 2048 characters.
Text *string `json:"text,omitempty"`
// Properties that control how the assistant responds.
Options *MessageInputOptions `json:"options,omitempty"`
// Intents to use when evaluating the user input. Include intents from the previous response to continue using those
// intents rather than trying to recognize intents in the new input.
Intents []RuntimeIntent `json:"intents,omitempty"`
// Entities to use when evaluating the message. Include entities from the previous response to continue using those
// entities rather than detecting entities in the new input.
Entities []RuntimeEntity `json:"entities,omitempty"`
// For internal use only.
SuggestionID *string `json:"suggestion_id,omitempty"`
}
MessageInput : The user input.
type MessageInputOptions ¶
type MessageInputOptions struct {
// Whether to return additional diagnostic information. Set to `true` to return additional information under the
// `output.debug` key.
Debug *bool `json:"debug,omitempty"`
// Whether to start a new conversation with this user input. Specify `true` to clear the state information stored by
// the session.
Restart *bool `json:"restart,omitempty"`
// Whether to return more than one intent. Set to `true` to return all matching intents.
AlternateIntents *bool `json:"alternate_intents,omitempty"`
// Whether to return session context with the response. If you specify `true`, the response will include the `context`
// property.
ReturnContext *bool `json:"return_context,omitempty"`
}
MessageInputOptions : Optional properties that control how the assistant responds.
type MessageOptions ¶
type MessageOptions struct {
// Unique identifier of the assistant. You can find the assistant ID of an assistant on the **Assistants** tab of the
// Watson Assistant tool. For information about creating assistants, see the
// [documentation](https://console.bluemix.net/docs/services/assistant/create-assistant.html#creating-assistants).
//
// **Note:** Currently, the v2 API does not support creating assistants.
AssistantID *string `json:"assistant_id" validate:"required"`
// Unique identifier of the session.
SessionID *string `json:"session_id" validate:"required"`
// An input object that includes the input text.
Input *MessageInput `json:"input,omitempty"`
// State information for the conversation.
Context *MessageContext `json:"context,omitempty"`
// Allows users to set headers to be GDPR compliant
Headers map[string]string
}
MessageOptions : The message options.
func (*MessageOptions) SetAssistantID ¶
func (options *MessageOptions) SetAssistantID(assistantID string) *MessageOptions
SetAssistantID : Allow user to set AssistantID
func (*MessageOptions) SetContext ¶
func (options *MessageOptions) SetContext(context *MessageContext) *MessageOptions
SetContext : Allow user to set Context
func (*MessageOptions) SetHeaders ¶
func (options *MessageOptions) SetHeaders(param map[string]string) *MessageOptions
SetHeaders : Allow user to set Headers
func (*MessageOptions) SetInput ¶
func (options *MessageOptions) SetInput(input *MessageInput) *MessageOptions
SetInput : Allow user to set Input
func (*MessageOptions) SetSessionID ¶
func (options *MessageOptions) SetSessionID(sessionID string) *MessageOptions
SetSessionID : Allow user to set SessionID
type MessageOutput ¶
type MessageOutput struct {
// Output intended for any channel. It is the responsibility of the client application to implement the supported
// response types.
Generic []DialogRuntimeResponseGeneric `json:"generic,omitempty"`
// An array of intents recognized in the user input, sorted in descending order of confidence.
Intents []RuntimeIntent `json:"intents,omitempty"`
// An array of entities identified in the user input.
Entities []RuntimeEntity `json:"entities,omitempty"`
// An array of objects describing any actions requested by the dialog node.
Actions []DialogNodeAction `json:"actions,omitempty"`
// Additional detailed information about a message response and how it was generated.
Debug *MessageOutputDebug `json:"debug,omitempty"`
}
MessageOutput : Assistant output to be rendered or processed by the client.
type MessageOutputDebug ¶
type MessageOutputDebug struct {
// An array of objects containing detailed diagnostic information about the nodes that were triggered during processing
// of the input message.
NodesVisited []DialogNodesVisited `json:"nodes_visited,omitempty"`
// An array of up to 50 messages logged with the request.
LogMessages []DialogLogMessage `json:"log_messages,omitempty"`
// Assistant sets this to true when this message response concludes or interrupts a dialog.
BranchExited *bool `json:"branch_exited,omitempty"`
// When `branch_exited` is set to `true` by the Assistant, the `branch_exited_reason` specifies whether the dialog
// completed by itself or got interrupted.
BranchExitedReason *string `json:"branch_exited_reason,omitempty"`
}
MessageOutputDebug : Additional detailed information about a message response and how it was generated.
type MessageResponse ¶
type MessageResponse struct {
// Assistant output to be rendered or processed by the client.
Output *MessageOutput `json:"output" validate:"required"`
// The current session context. Included in the response if the `return_context` property of the message input was set
// to `true`.
Context *MessageContext `json:"context,omitempty"`
}
MessageResponse : A response from the Watson Assistant service.
type RuntimeEntity ¶
type RuntimeEntity struct {
// An entity detected in the input.
Entity *string `json:"entity" validate:"required"`
// An array of zero-based character offsets that indicate where the detected entity values begin and end in the input
// text.
Location []int64 `json:"location" validate:"required"`
// The term in the input text that was recognized as an entity value.
Value *string `json:"value" validate:"required"`
// A decimal percentage that represents Watson's confidence in the entity.
Confidence *float64 `json:"confidence,omitempty"`
// Any metadata for the entity.
Metadata interface{} `json:"metadata,omitempty"`
// The recognized capture groups for the entity, as defined by the entity pattern.
Groups []CaptureGroup `json:"groups,omitempty"`
}
RuntimeEntity : A term from the request that was identified as an entity.
type RuntimeIntent ¶
type RuntimeIntent struct {
// The name of the recognized intent.
Intent *string `json:"intent" validate:"required"`
// A decimal percentage that represents Watson's confidence in the intent.
Confidence *float64 `json:"confidence" validate:"required"`
}
RuntimeIntent : An intent identified in the user input.
type SessionResponse ¶
type SessionResponse struct {
// The session ID.
SessionID *string `json:"session_id" validate:"required"`
}
SessionResponse : SessionResponse struct