How to Integrate Chat GPT-4 with Zoho CRM via the OpenAI API

How to Integrate Chat GPT-4 with Zoho CRM via the OpenAI API

Hey guys, 

Thanks for supporting my channel on YouTube.

This post is to go along with my video found at: https://youtu.be/X01FpA3455g

As promised, here is the code from this video:
  1. // Enter your OpenAI API Key
  2. apikey = "YOUR-API-KEY-HERE";
  3. // Set up the OpenAI API URL
  4. url = "https://api.openai.com/v1/chat/completions";
  5. Lead_Record = zoho.crm.getRecordById("Leads",Lead_ID);
  6. // Configure your prompt
  7. prompt = "An AI-generated response to the following input: " + Lead_Record.getJSON("Description");
  8. info "PROMPT IS: " + prompt;
  9. MessagesList = list();
  10. //
  11. Message_Map = Map();
  12. Message_Map.put("role","system");
  13. Message_Map.put("content","You are Chat GPT-4, a Large Language Model.");
  14. MessagesList.add(Message_Map);
  15. //
  16. Message_Map = Map();
  17. Message_Map.put("role","user");
  18. Message_Map.put("content",prompt);
  19. MessagesList.add(Message_Map);
  20. //
  21. params = Map();
  22. params.put("model","gpt-4");
  23. params.put("temperature",0.6);
  24. params.put("messages",MessagesList);
  25. params.put("max_tokens",4000);
  26. headers = Map();
  27. headers.put("Content-Type","application/json");
  28. headers.put("Authorization","Bearer " + apikey);
  29. // Make an API request to OpenAI
  30. response = invokeurl
  31. [
  32. url :url
  33. type :POST
  34. parameters:params.toString()
  35. headers:headers
  36. ];
  37. parsedResponse = response.getJSON("choices");
  38. generatedText = ifnull(parsedResponse.get(0).getJSON("message").getJSON("content"),"Failed to get Response: " + response);
  39. // Save the generated text to a desired field in Zoho CRM
  40. update = zoho.crm.updateRecord("Leads",Lead_ID,{"Description":generatedText});
  41. return update;
DON'T FORGET TO SET THE PARAMETER OF Lead_ID!

With the above code and the video on YouTube, you should be able to customise this for your needs, but if you would like my assistance to build an integration or a widget (like I have for my system), then please complete the following form (click here)

Here's the video script that my Zoho CRM Chat GPT-4 Widget wrote for me:



As you can see, the code that Chat GPT-4 generated for me is a good start, but required a lot of customisation!

I hope you enjoyed the video! If you did, please leave me a comment on the video and like the video! This really helps as it makes YouTube recommend my video to others and helps my channel grow.

Thank you!