Documentation
¶
Index ¶
- Constants
- Variables
- type Chat
- func (chat *Chat) GetFile(path string) (reader *request.Content, err error)
- func (chat Chat) GetFileURL(path string) *url.URL
- func (chat *Chat) GetParticipant(id string) (*Participant, error)
- func (chat Chat) IsWebUser(participantID string) bool
- func (chat *Chat) Reconnect() error
- func (chat *Chat) SendMessage(text, contentType string) error
- func (chat *Chat) Stop() error
- func (chat *Chat) String() string
- type ChatEvent
- type Client
- func (client Client) CurrentAPIEndpoint() *url.URL
- func (client *Client) GetServerConfiguration() (*ServerConfiguration, error)
- func (client *Client) NextAPIEndpoint() *url.URL
- func (client *Client) QueryQueue(queuename string, queuetype QueueType) (*Queue, error)
- func (client *Client) StartChat(options StartChatOptions) (*Chat, error)
- func (client *Client) URLWithPath(path string) *url.URL
- type ClientOptions
- type FileEvent
- type Participant
- type ParticipantStateChangedEvent
- type Queue
- type QueueType
- type RoutingContext
- type ServerConfiguration
- type StartChatOptions
- type StartEvent
- type Status
- type StopEvent
- type TextEvent
- type TypingIndicatorEvent
- type URLEvent
Constants ¶
const APP string = "IWT Agent"
APP is the name of the application
Variables ¶
var ( // StatusUnknownEntitySession means the provided session does not exist on the PureConnect Server StatusUnknownEntitySession = Status{"failure", "error.websvc.unknownEntity.session", nil} // StatusNotConnectedEntity means the client is not connected to any PureConnect Server StatusNotConnectedEntity = Status{"failure", "error.websvc.entity.notconnected", nil} StatusUnavailableService = Status{"failure", "error.websvc.unavailable", nil} )
var ( // SystemParticipant is used for messages sent by PureConnect SystemParticipant = Participant{Type: "System", ID: "00000000-0000-0000-0000-000000000000", Name: "System", State: "active"} )
var VERSION = "0.1.18" + commit
VERSION is the version of this application
Functions ¶
This section is empty.
Types ¶
type Chat ¶
type Chat struct {
ID string `json:"chatID"`
Queue *Queue `json:"queue"`
Participants []Participant `json:"participants"`
Guest Participant `json:"guest"` // used to store the id of the guest on their platform (LINE, KKT, etc)
PollWaitSuggestion time.Duration `json:"pollWaitSuggestion"`
Language string `json:"language"`
DateFormat string `json:"dateFormat"`
TimeFormat string `json:"timeFormat"`
EventChan chan ChatEvent `json:"-"`
PollTicker *time.Ticker `json:"-"`
Client *Client `json:"-"`
Logger *logger.Logger `json:"-"`
}
Chat describes a live chat
func (Chat) GetFileURL ¶ added in v0.1.5
GetFileURL tells the Download URL for the given file path
func (*Chat) GetParticipant ¶
func (chat *Chat) GetParticipant(id string) (*Participant, error)
GetParticipant fetches a participant from a chat by its ID
func (*Chat) Reconnect ¶
Reconnect reconnects the current chat to another server (Switchover event, e.g.)
func (*Chat) SendMessage ¶
SendMessage sends a message to the chat
type ChatEvent ¶
ChatEvent defines a Chat Event
func UnmarshalChatEvent ¶ added in v0.1.3
UnmarshalChatEvent unmarshals a JSON payload into a ChatEvent
type Client ¶
type Client struct {
APIEndpoints []*url.URL `json:"apiEndpoints"`
EndPointIndex int `json:"endpointIndex"`
Proxy *url.URL `json:"proxy"`
Language string `json:"language"`
CACert []byte `json:"cacert"`
Context context.Context `json:"-"`
Logger *logger.Logger `json:"-"`
}
Client is the IWT client to talk to PureConnect
func NewClient ¶
func NewClient(ctx context.Context, options ClientOptions) *Client
NewClient instantiates a new IWT Client
func (Client) CurrentAPIEndpoint ¶
CurrentAPIEndpoint gives the current API Endpoint to use
func (*Client) GetServerConfiguration ¶
func (client *Client) GetServerConfiguration() (*ServerConfiguration, error)
GetServerConfiguration fetches the configuration of the PureConnect server
func (*Client) NextAPIEndpoint ¶
NextAPIEndpoint switches to the next API endpoint (or back at the beginning)
func (*Client) QueryQueue ¶
QueryQueue queries a queue for its status
type ClientOptions ¶
type ClientOptions struct {
PrimaryAPI *url.URL `json:"primary"`
BackupAPI *url.URL `json:"backup"`
CACert []byte `json:"cacert"`
Proxy *url.URL `json:"proxy"`
Language string `json:"language"`
Logger *logger.Logger `json:"-"`
}
ClientOptions defines the options for instantiating a new IWT Client If you use https with the Primary/Backup API endpoint and they use a self-signed certificate, you must give the option CACert
type FileEvent ¶
type FileEvent struct {
SequenceNumber int `json:"sequenceNumber"`
ConversationSequenceNumber int `json:"conversationSequenceNumber"`
Participant Participant `json:"-"`
ContentType string `json:"contentType"`
Path string `json:"value"`
}
FileEvent describes the Text event
func (FileEvent) MarshalJSON ¶
MarshalJSON encodes into JSON
func (*FileEvent) UnmarshalJSON ¶ added in v0.1.3
UnmarshalJSON decodes JSON
type Participant ¶
type Participant struct {
Type string `json:"participantType"`
ID string `json:"participantID"`
Name string `json:"participantName"`
Credentials string `json:"credentials,omitempty"`
Picture *url.URL `json:"-"`
State string `json:"state,omitempty"`
Status Status `json:"status"`
}
Participant defines a chat participant
func (Participant) MarshalJSON ¶
func (participant Participant) MarshalJSON() ([]byte, error)
MarshalJSON encodes into JSON
func (*Participant) UnmarshalJSON ¶
func (participant *Participant) UnmarshalJSON(payload []byte) (err error)
UnmarshalJSON decodes JSON
type ParticipantStateChangedEvent ¶
type ParticipantStateChangedEvent struct {
SequenceNumber int `json:"sequenceNumber"`
Participant Participant `json:"-"`
}
ParticipantStateChangedEvent describes the ParticipantStateChanged event
func (ParticipantStateChangedEvent) GetType ¶
func (event ParticipantStateChangedEvent) GetType() string
GetType returns the type of this event
func (ParticipantStateChangedEvent) MarshalJSON ¶
func (event ParticipantStateChangedEvent) MarshalJSON() ([]byte, error)
MarshalJSON encodes into JSON
func (ParticipantStateChangedEvent) String ¶
func (event ParticipantStateChangedEvent) String() string
func (*ParticipantStateChangedEvent) UnmarshalJSON ¶ added in v0.1.3
func (event *ParticipantStateChangedEvent) UnmarshalJSON(payload []byte) (err error)
UnmarshalJSON decodes JSON
type Queue ¶
type Queue struct {
Name string `json:"queueName"`
Type QueueType `json:"queueType"`
EstimatedWaitTime int `json:"estimatedWaitTime"` // in H
PollWaitSuggestion int `json:"pollWaitSuggestion"` // in ms
AvailableAgents int `json:"agentsAvailable"`
Status Status `json:"status"`
}
Queue describe a queue
func NewQueue ¶
NewQueue instantiates a new Queue The Qualified Queue name follows the PureConnect standard way of specifying a queue: "User Queue:Operator", "Workgroup Queue:Sales", "Station Queue:7001" Workgroup Queue is the default type, and if nothing was given, "Workgroup Queue:CompanyOperator" will be used
type QueueType ¶
type QueueType int
QueueType defines the type of Queue
func (QueueType) MarshalJSON ¶
MarshalJSON encodes JSON
func (*QueueType) UnmarshalJSON ¶
UnmarshalJSON decodes JSON
type RoutingContext ¶
RoutingContext defines the routing context when starting a chat (see IWT documentation)
type ServerConfiguration ¶
type ServerConfiguration struct {
Version int `json:"cfgVer"`
Capabilities map[string][]string `json:"capabilities"`
}
ServerConfiguration contains information about a PureConnect server
type StartChatOptions ¶
type StartChatOptions struct {
Queue *Queue `json:"-"`
Guest Participant `json:"participant"`
Language string `json:"language,omitempty"`
EmailAddress string `json:"emailAddress,omitempty"`
SupportedContentTypes string `json:"supportedContentTypes"`
TranscriptRequired bool `json:"transcriptRequired"`
Attributes map[string]string `json:"attributes,omitempty"`
RoutingContexts []RoutingContext `json:"routingContexts,omitempty"`
}
StartChatOptions defines the options when starting a chat
type StartEvent ¶
type StartEvent struct {
ChatID string `json:"chatID"`
Participants []Participant `json:"participants"`
Guest Participant `json:"guest"` // used to store the id of the guest on their platform (LINE, KKT, etc)
Language string `json:"language"`
DateFormat string `json:"dateFormat"`
TimeFormat string `json:"timeFormat"`
}
StartEvent describes the Start event
func (StartEvent) GetType ¶
func (event StartEvent) GetType() string
GetType returns the type of this event
func (StartEvent) MarshalJSON ¶
func (event StartEvent) MarshalJSON() ([]byte, error)
MarshalJSON encodes into JSON
func (StartEvent) String ¶
func (event StartEvent) String() string
type Status ¶
type Status struct {
Type string `json:"type"`
Reason string `json:"reason"`
Params map[string]interface{} `json:"params"`
}
Status defines the status of a queue, chat, IWT request
type StopEvent ¶
type StopEvent struct {
ChatID string `json:"chatID"`
}
StopEvent describes the Text event
func (StopEvent) MarshalJSON ¶
MarshalJSON encodes into JSON
type TextEvent ¶
type TextEvent struct {
SequenceNumber int `json:"sequenceNumber"`
ConversationSequenceNumber int `json:"conversationSequenceNumber"`
Participant Participant `json:"-"`
ContentType string `json:"contentType"`
Text string `json:"value"`
}
TextEvent describes the Text event
func (TextEvent) MarshalJSON ¶
MarshalJSON encodes into JSON
func (*TextEvent) UnmarshalJSON ¶ added in v0.1.3
UnmarshalJSON decodes JSON
type TypingIndicatorEvent ¶
type TypingIndicatorEvent struct {
SequenceNumber int `json:"sequenceNumber"`
Participant Participant `json:"-"`
Typing bool `json:"value"`
}
TypingIndicatorEvent describes the TypingIndicator event
func (TypingIndicatorEvent) GetType ¶
func (event TypingIndicatorEvent) GetType() string
GetType returns the type of this event
func (TypingIndicatorEvent) MarshalJSON ¶
func (event TypingIndicatorEvent) MarshalJSON() ([]byte, error)
MarshalJSON encodes into JSON
func (TypingIndicatorEvent) String ¶
func (event TypingIndicatorEvent) String() string
func (*TypingIndicatorEvent) UnmarshalJSON ¶ added in v0.1.3
func (event *TypingIndicatorEvent) UnmarshalJSON(payload []byte) (err error)
UnmarshalJSON decodes JSON
type URLEvent ¶
type URLEvent struct {
SequenceNumber int `json:"sequenceNumber"`
Participant Participant `json:"-"`
URL *url.URL `json:"-"`
}
URLEvent describes the Text event
func (URLEvent) MarshalJSON ¶
MarshalJSON encodes into JSON
func (*URLEvent) UnmarshalJSON ¶
UnmarshalJSON decodes JSON