Home > Backend Development > Golang > Create a ticket on zendesk on behalf of user without sending email

Create a ticket on zendesk on behalf of user without sending email

WBOY
Release: 2024-02-05 21:48:04
forward
427 people have browsed it

代表用户在 zendesk 上创建票证,但不发送电子邮件

Question content

I'm using go and zendesk api to create tickets on behalf of a user, but I don't want the ticket creation email to be sent to the user. Is there any way to achieve this? This is my implementation:

func CreateZendeskTicket(title, body, email string) error {
    ticket := ZendeskTicket{
        Ticket: Ticket{
            Comment: Comment{
                Body: body,
            },
            Priority: "normal",
            Subject:  title,
            Requester: Requester{
                Email: email,
            },
        },
    }
    payload, err := json.Marshal(ticket)
    if err != nil {
        return err
    }
    url, _ := url.JoinPath(configs.CONFIG.Zendesk.BaseURL, "api/v2/tickets.json")
    req, err := http.NewRequest("POST", url, bytes.NewBuffer(payload))
    if err != nil {
        return err
    }

    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Basic "+configs.CONFIG.Zendesk.APIKey)

    client := &http.Client{}
    res, err := client.Do(req)
    if err != nil {
        return err
    }
    defer res.Body.Close()
    if res.StatusCode != 201 {
        return errors.New("Failed to create ticket: " + res.Status)
    }
    return nil
}
Copy after login

Correct answer


I finally found a way.

  1. Create the label and update the trigger so that it does not trigger any emails to the requester on the Zendesk dashboard
  2. Add a label to the tag when triggered.

The above is the detailed content of Create a ticket on zendesk on behalf of user without sending email. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template