customer

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: 5 Imported by: 0

Documentation

Overview

Package customer provides the client and structures for making Web API requests to Customer Chat API.

Detailed documentation of Customer Chat API is available here: https://developers.livechatinc.com/docs/messaging/customer-chat-api/.

All the methods of API have their analogue in Customer Chat API except for SendMessage and SendSystemMessage, which are specializations of SendEvent.

Customer Chat API Version

This API Client uses Customer Chat API in version 3.1.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	*i.API
}

API provides the API operation methods for making requests to Customer 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 Customer API.

If provided client is nil, then default http client with 20s timeout is used.

func (*API) ActivateChat

func (a *API) ActivateChat(initialChat *objects.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) CheckGoals

func (a *API) CheckGoals(pageURL string, groupID int, customerFields map[string]string) error

CheckGoals triggers checking if goals were achieved. Then, Agents receive the information. You should call this method to provide goals parameters for the server when the customers limit is reached. Works only for offline Customers.

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) 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) 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 string, offset, limit uint) (threads []objects.ThreadSummary, totak uint, err error)

GetChatThreadsSummary returns threads summary for given chat.

func (*API) GetChatsSummary

func (a *API) GetChatsSummary(offset, limit uint) (chats []objects.Chat, total uint, err error)

GetChatsSummary returns chats summary.

func (*API) GetCustomer

func (a *API) GetCustomer() (*objects.Customer, error)

GetCustomer returns current Customer.

func (*API) GetForm

func (a *API) GetForm(groupID int, formType FormType) (form *Form, enabled bool, err error)

GetForm returns an empty prechat, postchat or ticket form and indication whether the form is enabled on the license.

func (*API) GetGroupsStatus

func (a *API) GetGroupsStatus(groups []int) (map[int]GroupStatus, error)

GetGroupsStatus returns status of provided groups.

Possible values are: GroupStatusOnline, GroupStatusOffline and GroupStatusOnlineForQueue. GroupStatusUnknown should never be returned.

func (*API) GetPredictedAgent

func (a *API) GetPredictedAgent() (*PredictedAgent, error)

GetPredictedAgent returns the predicted Agent - the one the Customer will chat with when the chat starts. To use this method, the Customer needs to be logged in, which can be done via Customer Chat RTM Api's login method.

func (*API) GetURLDetails

func (a *API) GetURLDetails(url string) (*URLDetails, error)

GetURLDetails returns info on a given URL.

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 customer.

func (*API) SendEvent

func (a *API) SendEvent(chatID string, e interface{}) (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) SendMessage

func (a *API) SendMessage(chatID, text string, recipients Recipients) (string, error)

SendMessage sends event of type message to given chat. It returns event ID.

func (*API) SendRichMessagePostback

func (a *API) SendRichMessagePostback(chatID, threadID, eventID, postbackID string, toggled bool) error

SendRichMessagePostback sends postback for given rich message event.

func (*API) SendSneakPeek

func (a *API) SendSneakPeek(chatID, text string) error

SendSneakPeek sends sneak peek of message for given chat.

func (*API) SendSystemMessage

func (a *API) SendSystemMessage(chatID, text, messageType string, recipients Recipients) (string, error)

SendSystemMessage sends event of type system_message to given chat. It returns event ID.

func (*API) SetCustomerFields

func (a *API) SetCustomerFields(fields map[string]string) error

SetCustomerFields sets current customer's fields.

func (*API) StartChat

func (a *API) StartChat(initialChat *objects.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) 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(name, email, avatarURL string, fields map[string]string) error

UpdateCustomer updates current 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 Form

type Form struct {
	ID     string `json:"id"`
	Fields []struct {
		ID       string `json:"id"`
		Type     string `json:"type"`
		Label    string `json:"label"`
		Required bool   `json:"required"`
	} `json:"fields"`
}

Form struct describes schema of custom form (e-mail, prechat or postchat survey).

type FormType

type FormType string

FormType represents type of form templates.

const (
	FormTypePrechat  FormType = "prechat"
	FormTypePostchat FormType = "postchat"
	FormTypeTicket   FormType = "ticket"
	FormTypeEmail    FormType = "email"
)

Possible values of FormType.

type GroupStatus

type GroupStatus int

GroupStatus represents status of groups.

const (
	// GroupStatusUnknown should never be returned by API Client.
	GroupStatusUnknown GroupStatus = iota
	GroupStatusOnline
	GroupStatusOffline
	GroupStatusOnlineForQueue
)

Possible values of GroupStatus.

type PredictedAgent

type PredictedAgent struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	AvatarURL string `json:"avatar"`
	IsBot     bool   `json:"is_bot"`
	JobTitle  string `json:"job_title"`
	Type      string `json:"type"`
}

PredictedAgent is an agent returned by GetPredictedAgent method.

type Recipients

type Recipients string

Recipients represents possible event recipients.

const (
	All    Recipients = "all"
	Agents Recipients = "agents"
)

Possible values of Recipients.

type URLDetails

type URLDetails struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	URL         string `json:"url"`
	ImageURL    string `json:"image_url"`
	ImageWidth  int    `json:"image_width"`
	ImageHeight int    `json:"image_height"`
}

URLDetails contains some OpenGraph details of the URL.

Jump to

Keyboard shortcuts

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