agent

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

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

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

func NewStringFilter(values []string, inclusive bool) *stringFilter

NewStringFilter creates new filter for string values `inclusive` parameter controls if the filtered values should match or exclude given values

Types

type API

type API struct {
	*i.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

func (a *API) AddUserToChat(chatID, userID, userType string) error

AddUserToChat adds user to the chat. You can't add more than one customer type user to the chat.

func (*API) BanCustomer

func (a *API) BanCustomer(customerID string, days uint) error

BanCustomer bans customer for specific period of time (expressed in days).

func (*API) CloseThread

func (a *API) CloseThread(chatID string) error

CloseThread closes active thread for given chat. If no thread is active, then this method is a no-op.

func (*API) CreateCustomer

func (a *API) CreateCustomer(name, email, avatar string, fields map[string]string) (string, error)

CreateCustomer creates new Customer.

func (*API) DeleteChatProperties

func (a *API) DeleteChatProperties(chatID string, properties map[string][]string) error

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

func (a *API) FollowChat(chatID string) error

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

func (a *API) GetChatThreads(chatID string, threadIDs ...string) (objects.Chat, error)

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

func (a *API) GrantAccess(resource, id string, access objects.Access) error

GrantAccess grants access to a new resource without overwriting the existing ones.

func (*API) MarkEventsAsSeen

func (a *API) MarkEventsAsSeen(chatID string, seenUpTo time.Time) error

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

func (a *API) RemoveUserFromChat(chatID, userID, userType string) error

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

func (a *API) RevokeAccess(resource, id string, access objects.Access) error

RevokeAccess removes access to given resource.

func (*API) SendEvent

func (a *API) SendEvent(chatID string, event interface{}, attachToLastThread bool) (string, error)

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

func (a *API) SendTypingIndicator(chatID, recipients string, isTyping bool) error

SendTypingIndicator sends a notification about typing to defined recipients.

func (*API) SetAccess

func (a *API) SetAccess(resource, id string, access objects.Access) error

SetAccess gives access to a new resource overwriting the existing ones.

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

func (a *API) TagChatThread(chatID, threadID, tag string) error

TagChatThread adds given tag to chat thread.

func (*API) TransferChat

func (a *API) TransferChat(chatID, targetType string, ids []interface{}, force bool) error

TransferChat transfers chat to agent or group.

func (*API) UnfollowChat

func (a *API) UnfollowChat(chatID string) error

UnfollowChat removes requester from chat followers.

func (*API) UntagChatThread

func (a *API) UntagChatThread(chatID, threadID, tag string) error

UntagChatThread removes given tag from chat thread.

func (*API) UpdateAgent

func (a *API) UpdateAgent(agentID, routingStatus string) error

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

type PropertiesFilters map[string]map[string]*propertyFilterType

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

type SurveyFilter struct {
	Type     string `json:"type"`
	AnswerID string `json:"answer_id"`
}

SurveyFilter represents structure to match surveys when getting Archives

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL