Documentation
¶
Index ¶
- type AccessTokenSchema
- type AccountAddOptions
- type AccountAddSchema
- type AccountDelOptions
- type AccountInfoSchema
- type AccountListSchema
- type AccountUpdateOptions
- type AddContactWayOptions
- type AddContactWaySchema
- type BaseModel
- type Client
- func (r *Client) AccountAdd(options AccountAddOptions) (info AccountAddSchema, err error)
- func (r *Client) AccountDel(options AccountDelOptions) (info BaseModel, err error)
- func (r *Client) AccountList() (info AccountListSchema, err error)
- func (r *Client) AccountUpdate(options AccountUpdateOptions) (info BaseModel, err error)
- func (r *Client) AddContactWay(options AddContactWayOptions) (info AddContactWaySchema, err error)
- func (r *Client) CustomerBatchGet(options CustomerBatchGetOptions) (info CustomerBatchGetSchema, err error)
- func (r *Client) DecryptMsg(options CryptoOptions, postData []byte) ([]byte, error)
- func (r *Client) GetAccessToken() (info AccessTokenSchema, err error)
- func (r *Client) MediaGet(mediaID string) string
- func (r *Client) MediaOriginUpload(fileName, fileType string, size int, body []byte) (info MediaUploadSchema, err error)
- func (r *Client) MediaUpload(options MediaUploadOptions) (info MediaUploadSchema, err error)
- func (r *Client) ReceptionistAdd(options ReceptionistOptions) (info ReceptionistSchema, err error)
- func (r *Client) ReceptionistDel(options ReceptionistOptions) (info ReceptionistSchema, err error)
- func (r *Client) ReceptionistList(kfID string) (info ReceptionistListSchema, err error)
- func (r *Client) RefreshAccessToken() error
- func (r *Client) SendMsg(options interface{}) (info SendMsgSchema, err error)
- func (r *Client) ServiceStateGet(options ServiceStateGetOptions) (info ServiceStateGetSchema, err error)
- func (r *Client) ServiceStateTrans(options ServiceStateTransOptions) (info BaseModel, err error)
- func (r *Client) SyncMsg(options SyncMsgOptions) (info SyncMsgSchema, err error)
- func (r *Client) UpgradeGroupChatService(options UpgradeServiceGroupChatOptions) (info BaseModel, err error)
- func (r *Client) UpgradeMemberService(options UpgradeMemberServiceOptions) (info BaseModel, err error)
- func (r *Client) UpgradeService(options UpgradeServiceOptions) (info BaseModel, err error)
- func (r *Client) UpgradeServiceCancel(options UpgradeServiceCancelOptions) (info BaseModel, err error)
- func (r *Client) UpgradeServiceConfig() (info UpgradeServiceConfigSchema, err error)
- func (r *Client) VerifyURL(options CryptoOptions) (string, error)
- type CryptoOptions
- type CustomerBatchGetOptions
- type CustomerBatchGetSchema
- type CustomerSchema
- type Error
- type MediaUploadOptions
- type MediaUploadSchema
- type Options
- type ReceptionistListSchema
- type ReceptionistOptions
- type ReceptionistSchema
- type SendMsgSchema
- type ServiceStateGetOptions
- type ServiceStateGetSchema
- type ServiceStateTransOptions
- type SyncMsgOptions
- type SyncMsgSchema
- type UpgradeMemberServiceOptions
- type UpgradeServiceCancelOptions
- type UpgradeServiceConfigSchema
- type UpgradeServiceGroupChatOptions
- type UpgradeServiceOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessTokenSchema ¶
type AccessTokenSchema struct { BaseModel AccessToken string `json:"access_token"` // 获取到的凭证,最长为512字节 ExpiresIn int `json:"expires_in"` // 凭证的有效时间(秒) }
AccessTokenSchema 获取调用凭证响应数据
type AccountAddOptions ¶
type AccountAddOptions struct { Name string `json:"name"` // 客服帐号名称, 不多于16个字符 MediaID string `json:"media_id"` // 客服头像临时素材。可以调用上传临时素材接口获取, 不多于128个字节 }
AccountAddOptions 添加客服账号请求参数
type AccountAddSchema ¶
AccountAddSchema 添加客服账号响应内容
type AccountDelOptions ¶
type AccountDelOptions struct {
OpenKFID string `json:"open_kfid"` // 客服帐号ID, 不多于64字节
}
AccountDelOptions 删除客服账号请求参数
type AccountInfoSchema ¶
type AccountInfoSchema struct { OpenKFID string `json:"open_kfid"` // 客服帐号ID Name string `json:"name"` // 客服帐号名称 Avatar string `json:"avatar"` // 客服头像URL }
AccountInfoSchema 客服详情
type AccountListSchema ¶
type AccountListSchema struct { BaseModel AccountList []AccountInfoSchema `json:"account_list"` // 客服账号列表 }
AccountListSchema 获取客服账号列表响应内容
type AccountUpdateOptions ¶
type AccountUpdateOptions struct { OpenKFID string `json:"open_kfid"` // 客服帐号ID, 不多于64字节 Name string `json:"name"` // 客服帐号名称, 不多于16个字符 MediaID string `json:"media_id"` // 客服头像临时素材。可以调用上传临时素材接口获取, 不多于128个字节 }
AccountUpdateOptions 修改客服账号请求参数
type AddContactWayOptions ¶
type AddContactWayOptions struct { OpenKFID string `json:"open_kfid"` // 客服帐号ID, 不多于64字节 Scene string `json:"scene"` // 场景值,字符串类型,由开发者自定义, 不多于32字节, 字符串取值范围(正则表达式):[0-9a-zA-Z_-]* }
AddContactWayOptions 获取客服账号链接
type AddContactWaySchema ¶
type AddContactWaySchema struct { BaseModel URL string `json:"url"` // 客服链接,开发者可将该链接嵌入到H5页面中,用户点击链接即可向对应的微信客服帐号发起咨询。开发者也可根据该url自行生成需要的二维码图片 }
AddContactWaySchema 获取客服账号链接响应内容
type BaseModel ¶
type BaseModel struct { ErrCode int `json:"errcode"` // 出错返回码,为0表示成功,非0表示调用失败 ErrMsg string `json:"errmsg"` // 返回码提示语 }
BaseModel 基础数据
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 微信客服实例
func (*Client) AccountAdd ¶
func (r *Client) AccountAdd(options AccountAddOptions) (info AccountAddSchema, err error)
AccountAdd 添加客服账号
func (*Client) AccountDel ¶
func (r *Client) AccountDel(options AccountDelOptions) (info BaseModel, err error)
AccountDel 删除客服账号
func (*Client) AccountList ¶
func (r *Client) AccountList() (info AccountListSchema, err error)
AccountList 获取客服账号列表
func (*Client) AccountUpdate ¶
func (r *Client) AccountUpdate(options AccountUpdateOptions) (info BaseModel, err error)
AccountUpdate 修复客服账号
func (*Client) AddContactWay ¶
func (r *Client) AddContactWay(options AddContactWayOptions) (info AddContactWaySchema, err error)
AddContactWay 获取客服账号链接
func (*Client) CustomerBatchGet ¶
func (r *Client) CustomerBatchGet(options CustomerBatchGetOptions) (info CustomerBatchGetSchema, err error)
CustomerBatchGet 客户基本信息获取
func (*Client) DecryptMsg ¶
func (r *Client) DecryptMsg(options CryptoOptions, postData []byte) ([]byte, error)
DecryptMsg 解密消息
func (*Client) GetAccessToken ¶
func (r *Client) GetAccessToken() (info AccessTokenSchema, err error)
GetAccessToken 获取调用凭证access_token
func (*Client) MediaOriginUpload ¶ added in v0.0.28
func (r *Client) MediaOriginUpload(fileName, fileType string, size int, body []byte) (info MediaUploadSchema, err error)
MediaOriginUpload 上传临时素材 上传的媒体文件限制 所有文件size必须大于5个字节 图片(image):2MB,支持JPG,PNG格式 语音(voice) :2MB,播放长度不超过60s,仅支持AMR格式 视频(video) :10MB,支持MP4格式 普通文件(file):20MB
func (*Client) MediaUpload ¶
func (r *Client) MediaUpload(options MediaUploadOptions) (info MediaUploadSchema, err error)
MediaUpload 上传临时素材 上传的媒体文件限制 所有文件size必须大于5个字节 图片(image):2MB,支持JPG,PNG格式 语音(voice) :2MB,播放长度不超过60s,仅支持AMR格式 视频(video) :10MB,支持MP4格式 普通文件(file):20MB
func (*Client) ReceptionistAdd ¶ added in v0.0.4
func (r *Client) ReceptionistAdd(options ReceptionistOptions) (info ReceptionistSchema, err error)
ReceptionistAdd 添加接待人员
func (*Client) ReceptionistDel ¶ added in v0.0.4
func (r *Client) ReceptionistDel(options ReceptionistOptions) (info ReceptionistSchema, err error)
ReceptionistDel 删除接待人员
func (*Client) ReceptionistList ¶ added in v0.0.4
func (r *Client) ReceptionistList(kfID string) (info ReceptionistListSchema, err error)
ReceptionistList 获取接待人员列表
func (*Client) RefreshAccessToken ¶ added in v0.0.10
RefreshAccessToken 刷新调用凭证access_token
func (*Client) SendMsg ¶
func (r *Client) SendMsg(options interface{}) (info SendMsgSchema, err error)
SendMsg 获取消息
func (*Client) ServiceStateGet ¶ added in v0.0.7
func (r *Client) ServiceStateGet(options ServiceStateGetOptions) (info ServiceStateGetSchema, err error)
ServiceStateGet 获取会话状态 0 未处理 新会话接入。可选择:1.直接用API自动回复消息。2.放进待接入池等待接待人员接待。3.指定接待人员进行接待 1 由智能助手接待 可使用API回复消息。可选择转入待接入池或者指定接待人员处理。 2 待接入池排队中 在待接入池中排队等待接待人员接入。可选择转为指定人员接待 3 由人工接待 人工接待中。可选择结束会话 4 已结束 会话已经结束。不允许变更会话状态,等待用户重新发起咨询
func (*Client) ServiceStateTrans ¶ added in v0.0.7
func (r *Client) ServiceStateTrans(options ServiceStateTransOptions) (info BaseModel, err error)
ServiceStateTrans 变更会话状态
func (*Client) SyncMsg ¶
func (r *Client) SyncMsg(options SyncMsgOptions) (info SyncMsgSchema, err error)
SyncMsg 获取消息
func (*Client) UpgradeGroupChatService ¶ added in v0.0.28
func (r *Client) UpgradeGroupChatService(options UpgradeServiceGroupChatOptions) (info BaseModel, err error)
UpgradeGroupChatService 为客户升级为客户群服务
func (*Client) UpgradeMemberService ¶ added in v0.0.28
func (r *Client) UpgradeMemberService(options UpgradeMemberServiceOptions) (info BaseModel, err error)
UpgradeMemberService 为客户升级为专员服务
func (*Client) UpgradeService ¶ added in v0.0.6
func (r *Client) UpgradeService(options UpgradeServiceOptions) (info BaseModel, err error)
UpgradeService 为客户升级为专员或客户群服务
func (*Client) UpgradeServiceCancel ¶ added in v0.0.6
func (r *Client) UpgradeServiceCancel(options UpgradeServiceCancelOptions) (info BaseModel, err error)
UpgradeServiceCancel 为客户取消推荐
func (*Client) UpgradeServiceConfig ¶ added in v0.0.6
func (r *Client) UpgradeServiceConfig() (info UpgradeServiceConfigSchema, err error)
UpgradeServiceConfig 获取配置的专员与客户群
type CryptoOptions ¶
type CryptoOptions struct { Signature string `form:"msg_signature"` TimeStamp string `form:"timestamp"` Nonce string `form:"nonce"` EchoStr string `form:"echostr"` }
CryptoOptions 微信服务器验证参数
type CustomerBatchGetOptions ¶
type CustomerBatchGetOptions struct {
ExternalUserIDList []string `json:"external_userid_list"` // external_userid列表
}
CustomerBatchGetOptions 客户基本信息获取请求参数
type CustomerBatchGetSchema ¶
type CustomerBatchGetSchema struct { BaseModel CustomerList []CustomerSchema `json:"customer_list"` // 微信客户信息列表 InvalidExternalUserID []string `json:"invalid_external_userid"` // 无效的微信客户ID }
CustomerBatchGetSchema 获取客户基本信息响应内容
type CustomerSchema ¶
type CustomerSchema struct { ExternalUserID string `json:"external_userid"` // 微信客户的external_userid NickName string `json:"nickname"` // 微信昵称 Avatar string `json:"avatar"` // 微信头像。第三方不可获取 Gender int `json:"gender"` // 性别 UnionID string `json:"unionid"` // unionid,需要绑定微信开发者帐号才能获取到,查看绑定方法: https://open.work.weixin.qq.com/kf/doc/92512/93143/94769#%E5%A6%82%E4%BD%95%E8%8E%B7%E5%8F%96%E5%BE%AE%E4%BF%A1%E5%AE%A2%E6%88%B7%E7%9A%84unionid }
CustomerSchema 微信客户基本资料
type Error ¶ added in v0.0.10
type Error string
Error 错误
const ( // SDKInitFailed 错误码:50001 SDKInitFailed Error = "SDK初始化失败" SDKCacheUnavailable Error = "缓存无效" // SDKUnknownError 错误码:50003 SDKUnknownError Error = "未知错误" // SDKInvalidCredential 错误码:40001 SDKInvalidCredential Error = "不合法的secret参数" // SDKInvalidCorpID 错误码:40013 SDKInvalidCorpID Error = "无效的 CorpID" // SDKAccessTokenInvalid 错误码:40014 SDKAccessTokenInvalid Error = "AccessToken 无效" // SDKAccessTokenExpired 错误码:42001 SDKAccessTokenExpired Error = "AccessToken 已过期" // SDKWeWorkAlready 错误码:95011 SDKWeWorkAlready Error = "已在企业微信使用微信客服" )
type MediaUploadOptions ¶
type MediaUploadOptions struct { //上传文件类型 Type string `json:"type"` // 媒体文件类型,分别有图片(image)、语音(voice)、视频(video),普通文件(file) //文件名 FileName string `json:"fileName"` // 文件名 //文件大小 FileSize int64 `json:"fileSize"` // 文件大小 //文件内容 File multipart.File // 文件内容 }
MediaUploadOptions 上传临时素材请求参数
type MediaUploadSchema ¶
type MediaUploadSchema struct { BaseModel Type string `json:"type"` // 媒体文件类型,分别有图片(image)、语音(voice)、视频(video),普通文件(file) MediaID string `json:"media_id"` // 媒体文件上传后获取的唯一标识,3天内有效 CreatedAt string `json:"created_at"` // 媒体文件上传时间戳 }
MediaUploadSchema 上传临时素材响应内容
type Options ¶
type Options struct { CorpID string // 企业ID:企业开通的每个微信客服,都对应唯一的企业ID,企业可在微信客服管理后台的企业信息处查看 Secret string // Secret是微信客服用于校验开发者身份的访问密钥,企业成功注册微信客服后,可在「微信客服管理后台-开发配置」处获取 Token string // 用于生成签名校验回调请求的合法性 EncodingAESKey string // 回调消息加解密参数是AES密钥的Base64编码,用于解密回调消息内容对应的密文 Cache cache.Cache // 数据缓存 ExpireTime time.Duration // 令牌过期时间 IsCloseCache bool // 是否关闭自动缓存AccessToken, 默认缓存 }
Options 微信客服初始化参数
type ReceptionistListSchema ¶ added in v0.0.4
type ReceptionistListSchema struct { BaseModel ReceptionistList []struct { UserID string `json:"userid"` // 接待人员的userid。第三方应用获取到的为密文userid,即open_userid Status int `json:"status"` // 接待人员的接待状态。0:接待中,1:停止接待。第三方应用需具有“管理帐号、分配会话和收发消息”权限才可获取 } `json:"servicer_list"` }
ReceptionistListSchema 获取接待人员列表响应内容
type ReceptionistOptions ¶ added in v0.0.4
type ReceptionistOptions struct { OpenKFID string `json:"open_kfid"` // 客服帐号ID UserIDList []string `json:"userid_list"` // 接待人员userid列表 }
ReceptionistOptions 添加接待人员请求参数
type ReceptionistSchema ¶ added in v0.0.4
type ReceptionistSchema struct { BaseModel ResultList []struct { UserID string `json:"userid"` BaseModel } `json:"result_list"` }
ReceptionistSchema 添加接待人员响应内容
type SendMsgSchema ¶
type SendMsgSchema struct { BaseModel MsgID string `json:"msgid"` // 消息ID。如果请求参数指定了msgid,则原样返回,否则系统自动生成并返回。不多于32字节, 字符串取值范围(正则表达式):[0-9a-zA-Z_-]* }
SendMsgSchema 发送消息响应内容
type ServiceStateGetOptions ¶ added in v0.0.7
type ServiceStateGetOptions struct { OpenKFID string `json:"open_kfid"` // 客服帐号ID ExternalUserID string `json:"external_userid"` // 微信客户的external_userid }
ServiceStateGetOptions 获取会话状态请求参数
type ServiceStateGetSchema ¶ added in v0.0.7
type ServiceStateGetSchema struct { BaseModel ServiceState int `json:"service_state"` // 当前的会话状态,状态定义参考概述中的表格 ServiceUserID string `json:"service_userid"` // 接待人员的userid,仅当state=3时有效 }
ServiceStateGetSchema 获取会话状态响应内容
type ServiceStateTransOptions ¶ added in v0.0.7
type ServiceStateTransOptions struct { OpenKFID string `json:"open_kfid"` // 客服帐号ID ExternalUserID string `json:"external_userid"` // 微信客户的external_userid ServiceState int `json:"service_state"` // 变更的目标状态,状态定义和所允许的变更可参考概述中的流程图和表格 ServicerUserID string `json:"servicer_userid"` // 接待人员的userid,当state=3时要求必填 }
ServiceStateTransOptions 变更会话状态请求参数
type SyncMsgOptions ¶
type SyncMsgOptions struct { Cursor string `json:"cursor"` // 上一次调用时返回的next_cursor,第一次拉取可以不填, 不多于64字节 Token string `json:"token"` // 回调事件返回的token字段,10分钟内有效;可不填,如果不填接口有严格的频率限制, 不多于128字节 Limit uint `json:"limit"` // 期望请求的数据量,默认值和最大值都为1000, 注意:可能会出现返回条数少于limit的情况,需结合返回的has_more字段判断是否继续请求。 }
SyncMsgOptions 获取消息查询参数
type SyncMsgSchema ¶
type SyncMsgSchema struct { ErrCode int32 `json:"errcode"` // 返回码 ErrMsg string `json:"errmsg"` // 错误码描述 NextCursor string `json:"next_cursor"` // 下次调用带上该值则从该key值往后拉,用于增量拉取 HasMore uint32 `json:"has_more"` // 是否还有更多数据。0-否;1-是。不能通过判断msg_list是否空来停止拉取,可能会出现has_more为1,而msg_list为空的情况 MsgList []syncmsg.Message `json:"msg_list"` // 消息列表 }
SyncMsgSchema 获取消息查询响应内容
type UpgradeMemberServiceOptions ¶ added in v0.0.28
type UpgradeMemberServiceOptions struct { OpenKFID string `json:"open_kfid"` // 客服帐号ID ExternalUserID string `json:"external_userid"` // 微信客户的external_userid Type int `json:"type"` // 表示是升级到专员服务还是客户群服务。1:专员服务 Member struct { UserID string `json:"userid"` // 服务专员的userid Wording string `json:"wording"` // 推荐语 } `json:"member"` // 推荐的服务专员,type等于1时有效 }
UpgradeMemberServiceOptions 为客户升级为专员服务请求参数
type UpgradeServiceCancelOptions ¶ added in v0.0.6
type UpgradeServiceCancelOptions struct { OpenKFID string `json:"open_kfid"` // 客服帐号ID ExternalUserID string `json:"external_userid"` // 微信客户的external_userid }
UpgradeServiceCancelOptions 为客户取消推荐
type UpgradeServiceConfigSchema ¶ added in v0.0.6
type UpgradeServiceConfigSchema struct { BaseModel MemberRange struct { UserIDList []string `json:"userid_list"` // 专员userid列表 DepartmentIDList []string `json:"department_id_list"` // 专员部门列表 } `json:"member_range"` // 专员服务配置范围 GroupChatRange struct { ChatIDList []string `json:"chat_id_list"` // 客户群列表 } `json:"groupchat_range"` // 客户群配置范围 }
UpgradeServiceConfigSchema 获取配置的专员与客户群
type UpgradeServiceGroupChatOptions ¶ added in v0.0.28
type UpgradeServiceGroupChatOptions struct { OpenKFID string `json:"open_kfid"` // 客服帐号ID ExternalUserID string `json:"external_userid"` // 微信客户的external_userid Type int `json:"type"` // 表示是升级到专员服务还是客户群服务。2:客户群服务 GroupChat struct { ChatID string `json:"chat_id"` // 客户群id Wording string `json:"wording"` // 推荐语 } `json:"groupchat"` // 推荐的客户群,type等于2时有效 }
UpgradeServiceGroupChatOptions 为客户升级为客户群服务请求参数
type UpgradeServiceOptions ¶ added in v0.0.6
type UpgradeServiceOptions struct { OpenKFID string `json:"open_kfid"` // 客服帐号ID ExternalUserID string `json:"external_userid"` // 微信客户的external_userid Type int `json:"type"` // 表示是升级到专员服务还是客户群服务。1:专员服务。2:客户群服务 Member struct { UserID string `json:"userid"` // 服务专员的userid Wording string `json:"wording"` // 推荐语 } `json:"member"` // 推荐的服务专员,type等于1时有效 GroupChat struct { ChatID string `json:"chat_id"` // 客户群id Wording string `json:"wording"` // 推荐语 } `json:"groupchat"` // 推荐的客户群,type等于2时有效 }
UpgradeServiceOptions 为客户升级为专员或客户群服务请求参数