sdk

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountLabel

type AccountLabel struct {
	ID            int    `json:"id"`
	Title         string `json:"title"`
	Description   string `json:"description"`
	Color         string `json:"color"`
	ShowOnSidebar bool   `json:"show_on_sidebar"`
}

type AccountLabelsListResponse

type AccountLabelsListResponse struct {
	Payload []AccountLabel `json:"payload"`
}

type AccountLabelsService

type AccountLabelsService struct {
	// contains filtered or unexported fields
}

func (*AccountLabelsService) List

func (s *AccountLabelsService) List() ([]AccountLabel, error)

List returns all labels defined on the account.

type AddLabelsRequest

type AddLabelsRequest struct {
	Labels []string `json:"labels"`
}

type Agent

type Agent struct {
	ID                 int    `json:"id"`
	Name               string `json:"name"`
	Email              string `json:"email"`
	Thumbnail          string `json:"thumbnail"`
	AvailabilityStatus string `json:"availability_status"`
}

type AgentFull

type AgentFull struct {
	ID                 int    `json:"id"`
	Name               string `json:"name"`
	Email              string `json:"email"`
	AvailabilityStatus string `json:"availability_status"`
	Role               string `json:"role"`
	Thumbnail          string `json:"thumbnail"`
	AccountID          int    `json:"account_id"`
}

type AgentsService

type AgentsService struct {
	// contains filtered or unexported fields
}

func (*AgentsService) List

func (s *AgentsService) List() ([]AgentFull, error)

List returns all agents. The API returns a raw array, not wrapped in payload.

type AssignRequest

type AssignRequest struct {
	AssigneeID *int `json:"assignee_id,omitempty"`
	TeamID     int  `json:"team_id,omitempty"`
}

type Attachment

type Attachment struct {
	ID       int    `json:"id"`
	FileType string `json:"file_type"`
	DataURL  string `json:"data_url"`
	ThumbURL string `json:"thumb_url"`
	FileSize int    `json:"file_size"`
}

type Client

type Client struct {
	BaseURL   string
	APIKey    string
	AccountID int
	Verbose   bool
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseURL, apiKey string, accountID int, opts ...ClientOption) *Client

func (*Client) AccountLabels

func (c *Client) AccountLabels() *AccountLabelsService

AccountLabels returns the account-level labels service.

func (*Client) Agents

func (c *Client) Agents() *AgentsService

Agents returns the agents service

func (*Client) Contacts

func (c *Client) Contacts() *ContactsService

Contacts returns the contacts service

func (*Client) Conversations

func (c *Client) Conversations() *ConversationsService

Conversations returns the conversations service

func (*Client) Delete

func (c *Client) Delete(path string, v interface{}) error

func (*Client) Get

func (c *Client) Get(path string, params url.Values, v interface{}) error

func (*Client) GetRaw

func (c *Client) GetRaw(path string, params url.Values, v interface{}) error

GetRaw makes a GET request to a non-account-scoped path (e.g. /api/v1/profile).

func (*Client) Inboxes

func (c *Client) Inboxes() *InboxesService

Inboxes returns the inboxes service

func (*Client) Labels

func (c *Client) Labels(conversationID int) *LabelsService

Labels returns the labels service for a conversation

func (*Client) Messages

func (c *Client) Messages(conversationID int) *MessagesService

Messages returns the messages service for a conversation

func (*Client) Patch

func (c *Client) Patch(path string, body io.Reader, v interface{}) error

func (*Client) Post

func (c *Client) Post(path string, body io.Reader, v interface{}) error

func (*Client) Profile

func (c *Client) Profile() *ProfileService

Profile returns the profile service

func (*Client) Teams

func (c *Client) Teams() *TeamsService

Teams returns the teams service

type ClientOption

type ClientOption func(*Client)

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

func WithVerbose

func WithVerbose(verbose bool) ClientOption

type Contact

type Contact struct {
	ID         int    `json:"id"`
	Name       string `json:"name"`
	Email      string `json:"email"`
	Phone      string `json:"phone_number"`
	Thumbnail  string `json:"thumbnail"`
	Identifier string `json:"identifier"`
}

type ContactConversationsResponse

type ContactConversationsResponse struct {
	Payload []Conversation `json:"payload"`
}

type ContactFull

type ContactFull struct {
	ID                   int                    `json:"id"`
	Name                 string                 `json:"name"`
	Email                string                 `json:"email"`
	PhoneNumber          string                 `json:"phone_number"`
	Thumbnail            string                 `json:"thumbnail"`
	Identifier           string                 `json:"identifier"`
	CompanyName          string                 `json:"company_name,omitempty"`
	LastActivityAt       int64                  `json:"last_activity_at"`
	CreatedAt            int64                  `json:"created_at"`
	ConversationsCount   int                    `json:"conversations_count,omitempty"`
	CustomAttributes     map[string]interface{} `json:"custom_attributes"`
	AdditionalAttributes map[string]interface{} `json:"additional_attributes"`
}

type ContactsListOptions

type ContactsListOptions struct {
	Page int
	Sort string
}

type ContactsListResponse

type ContactsListResponse struct {
	Meta    map[string]interface{} `json:"meta"`
	Payload []ContactFull          `json:"payload"`
}

type ContactsSearchOptions

type ContactsSearchOptions struct {
	Query string
	Page  int
	Sort  string
}

type ContactsService

type ContactsService struct {
	// contains filtered or unexported fields
}

func (*ContactsService) Conversations

func (s *ContactsService) Conversations(id int) (*ContactConversationsResponse, error)

Conversations returns the conversations associated with a contact.

func (*ContactsService) Get

func (s *ContactsService) Get(id int) (*ContactFull, error)

func (*ContactsService) List

func (*ContactsService) Search

type Conversation

type Conversation struct {
	ID                   int                    `json:"id"`
	AccountID            int                    `json:"account_id"`
	InboxID              int                    `json:"inbox_id"`
	Status               string                 `json:"status"`
	Priority             *string                `json:"priority"`
	MessagesCount        int                    `json:"messages_count"`
	UnreadCount          int                    `json:"unread_count,omitempty"`
	CreatedAt            int64                  `json:"created_at"`
	Timestamp            int64                  `json:"timestamp"`
	LastActivityAt       int64                  `json:"last_activity_at"`
	ContactLastSeenAt    int64                  `json:"contact_last_seen_at"`
	AgentLastSeenAt      int64                  `json:"agent_last_seen_at"`
	Meta                 ConversationMeta       `json:"meta"`
	Labels               []string               `json:"labels"`
	AdditionalAttributes map[string]interface{} `json:"additional_attributes"`
	Messages             []Message              `json:"messages"`
}

type ConversationMeta

type ConversationMeta struct {
	Sender   *Contact `json:"sender"`
	Assignee *Agent   `json:"assignee"`
	Team     *Team    `json:"team"`
	Channel  string   `json:"channel"`
}

type ConversationsListResponse

type ConversationsListResponse struct {
	Data struct {
		Meta struct {
			AllCount        int `json:"all_count"`
			AssignedCount   int `json:"assigned_count"`
			UnassignedCount int `json:"unassigned_count"`
			MineCount       int `json:"mine_count"`
		} `json:"meta"`
		Payload []Conversation `json:"payload"`
	} `json:"data"`
}

type ConversationsService

type ConversationsService struct {
	// contains filtered or unexported fields
}

func (*ConversationsService) Assign

func (s *ConversationsService) Assign(id int, assigneeID *int, teamID int) (*User, error)

Assign updates the conversation's assignee and/or team. Pass a nil assigneeID to leave the agent assignment untouched (e.g. team-only assignment). Pass a pointer to 0 to explicitly unassign the agent.

func (*ConversationsService) Get

func (s *ConversationsService) Get(id int) (*Conversation, error)

func (*ConversationsService) List

func (*ConversationsService) ToggleStatus

func (s *ConversationsService) ToggleStatus(id int, status string, snoozedUntil *int64) (*ToggleStatusResponse, error)

func (*ConversationsService) Unassign

func (s *ConversationsService) Unassign(id int) error

func (*ConversationsService) UpdatePriority

func (s *ConversationsService) UpdatePriority(id int, priority string) error

UpdatePriority sets the conversation priority. Accepted values: "urgent", "high", "medium", "low". Pass "" to clear (sends JSON null).

Note: Chatwoot's swagger spec also lists "none" as a valid enum value, but the live toggle_priority endpoint returns 500 when sent literally. Sending null clears the priority cleanly.

type CreateMessageRequest

type CreateMessageRequest struct {
	Content           string                 `json:"content"`
	MessageType       string                 `json:"message_type,omitempty"`
	Private           bool                   `json:"private,omitempty"`
	ContentType       string                 `json:"content_type,omitempty"`
	ContentAttributes map[string]interface{} `json:"content_attributes,omitempty"`
	CampaignID        int                    `json:"campaign_id,omitempty"`
	TemplateParams    map[string]interface{} `json:"template_params,omitempty"`
}

type Inbox

type Inbox struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type InboxFull

type InboxFull struct {
	ID              int    `json:"id"`
	Name            string `json:"name"`
	ChannelType     string `json:"channel_type"`
	AvatarURL       string `json:"avatar_url"`
	ChannelID       int    `json:"channel_id,omitempty"`
	GreetingEnabled bool   `json:"greeting_enabled"`
	GreetingMessage string `json:"greeting_message"`
}

type InboxesListResponse

type InboxesListResponse struct {
	Payload []InboxFull `json:"payload"`
}

type InboxesService

type InboxesService struct {
	// contains filtered or unexported fields
}

func (*InboxesService) Get

func (s *InboxesService) Get(id int) (*InboxFull, error)

func (*InboxesService) List

type LabelsResponse

type LabelsResponse struct {
	Payload []string `json:"payload"`
}

type LabelsService

type LabelsService struct {
	// contains filtered or unexported fields
}

func (*LabelsService) Add

func (s *LabelsService) Add(labels []string) ([]string, error)

func (*LabelsService) List

func (s *LabelsService) List() ([]string, error)

type ListOptions

type ListOptions struct {
	Status       string
	InboxID      int
	AssigneeType string
	TeamID       int
	Query        string
	Page         int
	Labels       []string
	SortBy       string
}

type Message

type Message struct {
	ID                   int                    `json:"id"`
	Content              string                 `json:"content"`
	AccountID            int                    `json:"account_id"`
	InboxID              int                    `json:"inbox_id"`
	ConversationID       int                    `json:"conversation_id"`
	ContentType          string                 `json:"content_type"`
	ContentAttributes    map[string]interface{} `json:"content_attributes"`
	MessageType          int                    `json:"message_type"`
	Status               string                 `json:"status"`
	CreatedAt            int64                  `json:"created_at"`
	UpdatedAt            interface{}            `json:"updated_at"`
	Private              bool                   `json:"private"`
	SourceID             *string                `json:"source_id"`
	SenderType           *string                `json:"sender_type"`
	SenderID             *int                   `json:"sender_id"`
	AdditionalAttributes map[string]interface{} `json:"additional_attributes"`
	Sender               *MessageSender         `json:"sender"`
	Attachments          []Attachment           `json:"attachments"`
	Conversation         *MessageConversation   `json:"conversation"`
}

type MessageConversation

type MessageConversation struct {
	ID                int   `json:"id"`
	UnreadCount       int   `json:"unread_count"`
	LastActivityAt    int64 `json:"last_activity_at"`
	ContactLastSeenAt int64 `json:"contact_last_seen_at"`
	AgentLastSeenAt   int64 `json:"agent_last_seen_at"`
}

type MessageSender

type MessageSender struct {
	ID              int    `json:"id"`
	Name            string `json:"name"`
	Email           string `json:"email"`
	Type            string `json:"type"`
	Thumbnail       string `json:"thumbnail"`
	AvailableStatus string `json:"available_status,omitempty"`
}

type MessagesListResponse

type MessagesListResponse struct {
	Meta    map[string]interface{} `json:"meta"`
	Payload []Message              `json:"payload"`
}

type MessagesService

type MessagesService struct {
	// contains filtered or unexported fields
}

func (*MessagesService) Create

func (s *MessagesService) Create(content string, private bool) (*Message, error)

func (*MessagesService) CreateWithRequest

func (s *MessagesService) CreateWithRequest(body CreateMessageRequest) (*Message, error)

func (*MessagesService) Delete

func (s *MessagesService) Delete(messageID int) error

func (*MessagesService) List

func (s *MessagesService) List(beforeID int, afterID ...int) (*MessagesListResponse, error)

type ProfileResponse

type ProfileResponse struct {
	ID                 int                    `json:"id"`
	Name               string                 `json:"name"`
	Email              string                 `json:"email"`
	AvailabilityStatus string                 `json:"availability_status"`
	Role               string                 `json:"role"`
	Thumbnail          string                 `json:"thumbnail"`
	AvatarURL          string                 `json:"avatar_url"`
	AccountID          int                    `json:"account_id"`
	UISettings         map[string]interface{} `json:"ui_settings"`
}

type ProfileService

type ProfileService struct {
	// contains filtered or unexported fields
}

func (*ProfileService) Get

func (s *ProfileService) Get() (*ProfileResponse, error)

Get fetches the current user's profile. Uses a non-account-scoped endpoint.

type Team

type Team struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type TeamFull

type TeamFull struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	AccountID   int    `json:"account_id"`
}

type TeamsService

type TeamsService struct {
	// contains filtered or unexported fields
}

func (*TeamsService) List

func (s *TeamsService) List() ([]TeamFull, error)

List returns all teams. The API returns a raw array, not wrapped in payload.

type ToggleStatusRequest

type ToggleStatusRequest struct {
	Status       string `json:"status"`
	SnoozedUntil *int64 `json:"snoozed_until,omitempty"`
}

type ToggleStatusResponse

type ToggleStatusResponse struct {
	Success        bool   `json:"success"`
	CurrentStatus  string `json:"current_status"`
	ConversationID int    `json:"conversation_id"`
}

type UpdatePriorityRequest

type UpdatePriorityRequest struct {
	Priority *string `json:"priority"`
}

type User

type User struct {
	ID                 int                    `json:"id"`
	AccessToken        string                 `json:"access_token"`
	AccountID          int                    `json:"account_id"`
	AvailableName      string                 `json:"available_name"`
	AvatarURL          string                 `json:"avatar_url"`
	Confirmed          bool                   `json:"confirmed"`
	DisplayName        *string                `json:"display_name"`
	MessageSignature   *string                `json:"message_signature"`
	Email              string                 `json:"email"`
	HMACIdentifier     string                 `json:"hmac_identifier"`
	InviterID          *int                   `json:"inviter_id"`
	Name               string                 `json:"name"`
	Provider           string                 `json:"provider"`
	PubsubToken        string                 `json:"pubsub_token"`
	Role               string                 `json:"role"`
	UISettings         map[string]interface{} `json:"ui_settings"`
	UID                string                 `json:"uid"`
	Type               *string                `json:"type"`
	CustomAttributes   map[string]interface{} `json:"custom_attributes"`
	AvailabilityStatus string                 `json:"availability_status"`
}

Jump to

Keyboard shortcuts

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