diff --git a/qyweixin/app_customer.go b/qyweixin/app_customer.go index ef70e84..6d3635f 100644 --- a/qyweixin/app_customer.go +++ b/qyweixin/app_customer.go @@ -93,6 +93,8 @@ type CustomerEvent struct { ChangeType int `json:"change_type"` OldServicerUserid string `json:"old_servicer_userid"` NewServicerUserid string `json:"new_servicer_userid"` + MsgCode string `json:"msg_code"` + WelcomeCode string `json:"welcome_code"` } 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 { reqUrl := fmt.Sprintf("https://qyapi.weixin.qq.com/cgi-bin/kf/send_msg?access_token=%s", a.GetToken()) params := make(map[string]interface{})