Documentation ¶
Overview ¶
Package agent provides the client and structures for making Web API requests to Agent Chat API.
Detailed documentation of Agent Chat API is available here: https://developers.livechatinc.com/docs/messaging/agent-chat-api/.
All the methods of API have their analogue in Agent Chat API ¶
Agent Chat API Version ¶
This API Client uses Agent Chat API in version 3.1.
Index ¶
- func NewArchivesFilters() *archivesFilters
- func NewChatsFilters() *chatsFilters
- func NewCustomersFilters() *customersFilters
- func NewPropertyFilterType(includes bool, vals ...interface{}) *propertyFilterType
- func NewStringFilter(values []string, inclusive bool) *stringFilter
- type API
- func (a *API) ActivateChat(initialChat *InitialChat, continuous bool) (threadID string, eventIDs []string, err error)
- func (a *API) AddUserToChat(chatID, userID, userType string) error
- func (a *API) BanCustomer(customerID string, days uint) error
- func (a *API) CloseThread(chatID string) error
- func (a *API) CreateCustomer(name, email, avatar string, fields map[string]string) (string, error)
- func (a *API) DeleteChatProperties(chatID string, properties map[string][]string) error
- func (a *API) DeleteChatThreadProperties(chatID, threadID string, properties map[string][]string) error
- func (a *API) DeleteEventProperties(chatID, threadID, eventID string, properties map[string][]string) error
- func (a *API) FollowChat(chatID string) error
- func (a *API) GetArchives(filters *archivesFilters, page, limit uint) (chats []objects.Chat, currentPage, totalPages uint, err error)
- func (a *API) GetChatThreads(chatID string, threadIDs ...string) (objects.Chat, error)
- func (a *API) GetChatThreadsSummary(chatID, order, pageID string, limit uint) (summary []objects.ThreadSummary, found uint, previousPage, nextPage string, ...)
- func (a *API) GetChatsSummary(filters *chatsFilters, page, limit uint) (summary []objects.ChatSummary, found uint, previousPage, nextPage string, ...)
- func (a *API) GetCustomers(limit uint, pageID, order string, filters *customersFilters) (customers []objects.Customer, total uint, previousPage, nextPage string, ...)
- func (a *API) GrantAccess(resource, id string, access objects.Access) error
- func (a *API) MarkEventsAsSeen(chatID string, seenUpTo time.Time) error
- func (a *API) Multicast(scopes MulticastScopes, content json.RawMessage, multicastType string) error
- func (a *API) RemoveUserFromChat(chatID, userID, userType string) error
- func (a *API) RevokeAccess(resource, id string, access objects.Access) error
- func (a *API) SendEvent(chatID string, event interface{}, attachToLastThread bool) (string, error)
- func (a *API) SendRichMessagePostback(chatID, eventID, threadID, postbackID string, toggled bool) error
- func (a *API) SendTypingIndicator(chatID, recipients string, isTyping bool) error
- func (a *API) SetAccess(resource, id string, access objects.Access) error
- func (a *API) StartChat(initialChat *InitialChat, continuous bool) (chatID, threadID string, eventIDs []string, err error)
- func (a *API) TagChatThread(chatID, threadID, tag string) error
- func (a *API) TransferChat(chatID, targetType string, ids []interface{}, force bool) error
- func (a *API) UnfollowChat(chatID string) error
- func (a *API) UntagChatThread(chatID, threadID, tag string) error
- func (a *API) UpdateAgent(agentID, routingStatus string) error
- func (a *API) UpdateChatProperties(chatID string, properties objects.Properties) error
- func (a *API) UpdateChatThreadProperties(chatID, threadID string, properties objects.Properties) error
- func (a *API) UpdateCustomer(customerID, name, email, avatar string, fields map[string]string) (objects.Customer, error)
- func (a *API) UpdateEventProperties(chatID, threadID, eventID string, properties objects.Properties) error
- type DateRangeFilter
- type InitialChat
- type MulticastScopes
- type MulticastScopesAgents
- type MulticastScopesCustomers
- type PropertiesFilters
- type RangeFilter
- type SurveyFilter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewArchivesFilters ¶
func NewArchivesFilters() *archivesFilters
NewArchivesFilters creates empty structure to aggregate filters for GetArchives method
func NewChatsFilters ¶
func NewChatsFilters() *chatsFilters
NewChatsFilters creates empty structure to aggregate filters for Chats in GetChatsSummary method By default filters include also active chats
func NewCustomersFilters ¶
func NewCustomersFilters() *customersFilters
NewCustomersFilters creates empty structure to aggregate filters for customers in GetCustomers method
func NewPropertyFilterType ¶
func NewPropertyFilterType(includes bool, vals ...interface{}) *propertyFilterType
NewPropertyFilterType creates new filter object for Chat properties If only first parameter is passed, filter will check only existence of property Passing additional parameters will check if property values match/exclude given values based on the first parameter
func NewStringFilter ¶
NewStringFilter creates new filter for string values `inclusive` parameter controls if the filtered values should match or exclude given values
Types ¶
type API ¶
API provides the API operation methods for making requests to Agent Chat API via Web API. See this package's package overview docs for details on the service.
func NewAPI ¶
func NewAPI(t authorization.TokenGetter, client *http.Client, clientID string) (*API, error)
NewAPI returns ready to use Agent API.
If provided client is nil, then default http client with 20s timeout is used.
func (*API) ActivateChat ¶
func (a *API) ActivateChat(initialChat *InitialChat, continuous bool) (threadID string, eventIDs []string, err error)
ActivateChat activates chat initialChat.ID with access, properties and initial thread as defined in initialChat. It returns respectively thread ID and initial event IDs (except for server-generated events).
func (*API) AddUserToChat ¶
AddUserToChat adds user to the chat. You can't add more than one customer type user to the chat.
func (*API) BanCustomer ¶
BanCustomer bans customer for specific period of time (expressed in days).
func (*API) CloseThread ¶
CloseThread closes active thread for given chat. If no thread is active, then this method is a no-op.
func (*API) CreateCustomer ¶
CreateCustomer creates new Customer.
func (*API) DeleteChatProperties ¶
DeleteChatProperties deletes given chat's properties.
func (*API) DeleteChatThreadProperties ¶
func (a *API) DeleteChatThreadProperties(chatID, threadID string, properties map[string][]string) error
DeleteChatThreadProperties deletes given chat thread's properties.
func (*API) DeleteEventProperties ¶
func (a *API) DeleteEventProperties(chatID, threadID, eventID string, properties map[string][]string) error
DeleteEventProperties deletes given event's properties.
func (*API) FollowChat ¶
FollowChat marks given chat as followed by requester.
func (*API) GetArchives ¶
func (a *API) GetArchives(filters *archivesFilters, page, limit uint) (chats []objects.Chat, currentPage, totalPages uint, err error)
GetArchives returns archived chats.
func (*API) GetChatThreads ¶
GetChatThreads returns given threads, or all if no threads are provided, for given chat.
func (*API) GetChatThreadsSummary ¶
func (a *API) GetChatThreadsSummary(chatID, order, pageID string, limit uint) (summary []objects.ThreadSummary, found uint, previousPage, nextPage string, err error)
GetChatThreadsSummary returns threads summary for given chat.
func (*API) GetChatsSummary ¶
func (a *API) GetChatsSummary(filters *chatsFilters, page, limit uint) (summary []objects.ChatSummary, found uint, previousPage, nextPage string, err error)
GetChatsSummary returns chats summary.
func (*API) GetCustomers ¶
func (a *API) GetCustomers(limit uint, pageID, order string, filters *customersFilters) (customers []objects.Customer, total uint, previousPage, nextPage string, err error)
GetCustomers returns the list of Customers.
func (*API) GrantAccess ¶
GrantAccess grants access to a new resource without overwriting the existing ones.
func (*API) MarkEventsAsSeen ¶
MarkEventsAsSeen marks all events up to given date in given chat as seen for current agent.
func (*API) Multicast ¶
func (a *API) Multicast(scopes MulticastScopes, content json.RawMessage, multicastType string) error
Multicast method serves for the chat-unrelated communication. Messages sent using multicast are not being saved.
func (*API) RemoveUserFromChat ¶
RemoveUserFromChat Removes a user from chat. Removing customer user type is not allowed. It's always possible to remove the requester from the chat.
func (*API) RevokeAccess ¶
RevokeAccess removes access to given resource.
func (*API) SendEvent ¶
SendEvent sends event of supported type to given chat. It returns event ID.
Supported event types are: event, message, system_message and file.
func (*API) SendRichMessagePostback ¶
func (a *API) SendRichMessagePostback(chatID, eventID, threadID, postbackID string, toggled bool) error
SendRichMessagePostback sends postback for given rich message event.
func (*API) SendTypingIndicator ¶
SendTypingIndicator sends a notification about typing to defined recipients.
func (*API) StartChat ¶
func (a *API) StartChat(initialChat *InitialChat, continuous bool) (chatID, threadID string, eventIDs []string, err error)
StartChat starts new chat with access, properties and initial thread as defined in initialChat. It returns respectively chat ID, thread ID and initial event IDs (except for server-generated events).
func (*API) TagChatThread ¶
TagChatThread adds given tag to chat thread.
func (*API) TransferChat ¶
TransferChat transfers chat to agent or group.
func (*API) UnfollowChat ¶
UnfollowChat removes requester from chat followers.
func (*API) UntagChatThread ¶
UntagChatThread removes given tag from chat thread.
func (*API) UpdateAgent ¶
UpdateAgent updates agent's info.
func (*API) UpdateChatProperties ¶
func (a *API) UpdateChatProperties(chatID string, properties objects.Properties) error
UpdateChatProperties updates given chat's properties.
func (*API) UpdateChatThreadProperties ¶
func (a *API) UpdateChatThreadProperties(chatID, threadID string, properties objects.Properties) error
UpdateChatThreadProperties updates given chat thread's properties.
func (*API) UpdateCustomer ¶
func (a *API) UpdateCustomer(customerID, name, email, avatar string, fields map[string]string) (objects.Customer, error)
UpdateCustomer updates customer's info.
func (*API) UpdateEventProperties ¶
func (a *API) UpdateEventProperties(chatID, threadID, eventID string, properties objects.Properties) error
UpdateEventProperties updates given event's properties.
type DateRangeFilter ¶
type DateRangeFilter struct { LTE string `json:"lte,omitempty"` LT string `json:"lt,omitempty"` GTE string `json:"gte,omitempty"` GT string `json:"gt,omitempty"` EQ string `json:"eq,omitempty"` }
DateRangeFilter represents structure to define a range in which filtered dates should be matched Dates are represented in ISO 8601 format with microseconds resolution, e.g. 2017-10-12T15:19:21.010200+01:00 in specific timezone or 2017-10-12T14:19:21.010200Z in UTC. LTE - less than or equal LT - less than GTE - greater than or equal GT - greater than EQ - equal
type InitialChat ¶
type InitialChat struct { objects.InitialChat Users []*objects.User `json:"users,omitempty"` }
type MulticastScopes ¶
type MulticastScopes struct { Agents *MulticastScopesAgents `json:"agents,omitempty"` Customers *MulticastScopesCustomers `json:"customers,omitempty"` }
MulticastScopes aggregates Agent and Customer Scopes that multicast should be sent to
type MulticastScopesAgents ¶
type MulticastScopesAgents struct { Groups []uint `json:"groups,omitempty"` IDs []string `json:"ids,omitempty"` All *bool `json:"all,omitempty"` }
MulticastScopesAgents represents scopes for multicast to agents
type MulticastScopesCustomers ¶
type MulticastScopesCustomers struct {
IDs []string `json:"ids,omitempty"`
}
MulticastScopesCustomers represents scopes for multicast to customers
type PropertiesFilters ¶
PropertiesFilters represents set of filters for Chat properties
type RangeFilter ¶
type RangeFilter struct { LTE int `json:"lte,omitempty"` LT int `json:"lt,omitempty"` GTE int `json:"gte,omitempty"` GT int `json:"gt,omitempty"` EQ int `json:"eq,omitempty"` }
RangeFilter represents structure to define a range in which filtered numbers should be matched LTE - less than or equal LT - less than GTE - greater than or equal GT - greater than EQ - equal
type SurveyFilter ¶
SurveyFilter represents structure to match surveys when getting Archives