welcomeCode

This commit is contained in:
jiangyong27 2024-07-27 10:36:49 +08:00
parent 616f26f45b
commit f37bcd9878
1 changed files with 22 additions and 0 deletions

View File

@ -93,6 +93,8 @@ type CustomerEvent struct {
ChangeType int `json:"change_type"` ChangeType int `json:"change_type"`
OldServicerUserid string `json:"old_servicer_userid"` OldServicerUserid string `json:"old_servicer_userid"`
NewServicerUserid string `json:"new_servicer_userid"` NewServicerUserid string `json:"new_servicer_userid"`
MsgCode string `json:"msg_code"`
WelcomeCode string `json:"welcome_code"`
} }
type CustomerInfo struct { type CustomerInfo struct {
@ -263,6 +265,26 @@ func (a *AppCustomer) SendCustomerFile(openKfId, toUser, mediaId string) error {
}) })
} }
func (a *AppCustomer) SendCustomerWelcome(code, message string) error {
reqUrl := fmt.Sprintf("https://qyapi.weixin.qq.com/cgi-bin/kf/send_msg_on_event?access_token=?access_token=%s", a.GetToken())
params := make(map[string]interface{})
params["code"] = code
params["text"] = map[string]interface{}{
"content": message,
}
reqBody, _ := json.Marshal(params)
rspBody, err := util.HttpPostJson(reqUrl, nil, reqBody)
if err != nil {
return err
}
_, err = a.GetResult(rspBody)
if err != nil {
return err
}
return nil
}
func (a *AppCustomer) sendCustomerMessage(openKfId, toUser, msgtype string, data interface{}) error { func (a *AppCustomer) sendCustomerMessage(openKfId, toUser, msgtype string, data interface{}) error {
reqUrl := fmt.Sprintf("https://qyapi.weixin.qq.com/cgi-bin/kf/send_msg?access_token=%s", a.GetToken()) reqUrl := fmt.Sprintf("https://qyapi.weixin.qq.com/cgi-bin/kf/send_msg?access_token=%s", a.GetToken())
params := make(map[string]interface{}) params := make(map[string]interface{})