How to Integrate Chat GPT-4 with Zoho CRM via the OpenAI API
Hey guys,
Thanks for supporting my channel on YouTube.
As promised, here is the code from this video:
- // Enter your OpenAI API Key
- apikey = "YOUR-API-KEY-HERE";
- // Set up the OpenAI API URL
- url = "https://api.openai.com/v1/chat/completions";
- Lead_Record = zoho.crm.getRecordById("Leads",Lead_ID);
- // Configure your prompt
- prompt = "An AI-generated response to the following input: " + Lead_Record.getJSON("Description");
- info "PROMPT IS: " + prompt;
- MessagesList = list();
- //
- Message_Map = Map();
- Message_Map.put("role","system");
- Message_Map.put("content","You are Chat GPT-4, a Large Language Model.");
- MessagesList.add(Message_Map);
- //
- Message_Map = Map();
- Message_Map.put("role","user");
- Message_Map.put("content",prompt);
- MessagesList.add(Message_Map);
- //
- params = Map();
- params.put("model","gpt-4");
- params.put("temperature",0.6);
- params.put("messages",MessagesList);
- params.put("max_tokens",4000);
- headers = Map();
- headers.put("Content-Type","application/json");
- headers.put("Authorization","Bearer " + apikey);
- // Make an API request to OpenAI
- response = invokeurl
- [
- url :url
- type :POST
- parameters:params.toString()
- headers:headers
- ];
- parsedResponse = response.getJSON("choices");
- generatedText = ifnull(parsedResponse.get(0).getJSON("message").getJSON("content"),"Failed to get Response: " + response);
- // Save the generated text to a desired field in Zoho CRM
- update = zoho.crm.updateRecord("Leads",Lead_ID,{"Description":generatedText});
- 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!