How to Resolve Invalid Request Issue when Integrating OpenAI with Zendesk?

This topic was automatically generated from Slack. You can find the original thread here.

Hi all, I’m hitting an odd roadblock trying to integrate OpenAI with Zendesk. Receiving an invalid request with my JSON but I confirmed that the variables from my call match what Zendesk is expecting and it is valid JSON. Any ideas?

This is my call:

{
“model”: “gpt-3.5-turbo”,
“messages”: [
{
“role”: “system”,
“content”: “You are a helpful customer support assistant integrated into Zendesk. Provide internal notes to help agents respond to tickets effectively.”
},
{
“role”: “user”,
“content”: “Here is a new ticket that needs analysis and a suggested response:\n\nTicket Title: {{steps.trigger.event.title}}\nTicket Description: {{steps.trigger.event.description}}\nRequester: {{steps.trigger.event.requester}}\nStatus: {{steps.trigger.event.status}}\nTicket URL: {{steps.trigger.event.url}}\n\nBased on this information, suggest a concise and actionable internal note for the agent. If additional resources (knowledge base articles or macros) should be created, include that suggestion.”
}
],
“temperature”: 0.7,
“max_tokens”: 200
}

What does the rest of that message say?

Did you try the Debug with AI button?

It wasn’t really helpful because it says my call was wrong

The error indicates a 400 Bad Request, which often means there’s an issue with the request payload or headers.

  1. Ensure the “Http account linked” is set to true, as it currently shows “false”. This might indicate a missing or incorrect authentication setup.
  2. Verify the “token” in the HTTP Request Configuration is valid and has the necessary permissions for the OpenAI API.
  3. Double-check the JSON structure in the “raw” body field for any syntax errors or missing required fields.
    Correct these issues and try again.

What does the rest of the message in that error object say?

Seems like a syntax issue maybe

Can you show more of your step configuration?

The trigger from Zendesk or the call from OpenAI?

To call to OpenAI. That’s what’s failing, right?

I believe so

Sorry, I just deleted that message, since it contained your API key in the clear

yea just realized that

Can you show me the body you’re POSTing?

{
  "model": "gpt-3.5-turbo",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful customer support assistant integrated into Zendesk. Provide internal notes to help agents respond to tickets effectively."
    },
    {
      "role": "user",
      "content": "Here is a new ticket that needs analysis and a suggested response:\n\nTicket Title: {{steps.trigger.event.title}}\nTicket Description: {{steps.trigger.event.description}}\nRequester: {{steps.trigger.event.requester}}\nStatus: {{steps.trigger.event.status}}\nTicket URL: {{steps.trigger.event.url}}\n\nBased on this information, suggest a concise and actionable internal note for the agent. If additional resources (knowledge base articles or macros) should be created, include that suggestion."
    }
  ],
  "temperature": 0.7,
  "max_tokens": 200
}

Hm, not seeing anything immediately wrong. Is Content-Type set to application/json?

Yes,

It seems that the payload is getting malformed somehow when it is sent