User Tips: Create a bot & have users chatting with ChatGPT in 30 seconds!

User Tips: Create a bot & have users chatting with ChatGPT in 30 seconds!

If you want your users to be able to chat 1-1 with a bot, this post is for you! This builds on the great post by Poorvik Palanikumar here that walked users through the process of creating a bot that could respond on a channel. If you followed that post and set everything up can can skip to "3." below and continue from there.

(The lazy instructions... Copy code below, create a bot, click "edit code" for the message handler & paste the code, insert your own token and save.)

To create & enable a bot to respond privately to user instead of on a channel follow the steps below.
  1. Create a bot. (Click your profile pic>Bots & Tools > "Create Bot" (top right)
  2. Name the Bot, add description and set it to "Organization" and Save
  3. Click "Edit Code" from the "Message Handler" section and delete the existing code (presuming you don't use it!)
  4. Paste in the code below and save. Make sure to add in your own token. Get one here
You're all set! Go and subscribe to your bot and ask it a question... you'll have to grant permissions from the popup message.

Message Handler Code: 
(Bots & Tools > Edit Handlers (for your bot) > Go to Message Handler & click "Edit Code")

response = Map();
//
//Reassign the inbound message from the user, which we'll send to ChatGPT
question = message;
//
//
// Need to add your OWN openAI token below. Replace the xxxxxxx with your own token
token = "Bearer xxxxxxxxxxxxxxxx";
//
//
header = Map();
header.put("Authorization", token);
header.put("Content-Type", "application/json");
//
//
//Set the params which we'll send to chatGPT
//Increasing the temperature increases response creativity, decreasing has the opposite affect
params = { "model": "text-davinci-003", "prompt": question, "temperature": 0.4, "top_p": 1
"max_tokens": 256, "frequency_penalty": 0, "presence_penalty": 0, "stop": { " Human:", " AI:"} };
//
//
// Making post request to ChatGPT
fetchCompletions = invokeurl
[
type: POST
parameters: params.toString()
headers: header
detailed: true
];
//
//
info "Fetch completions: " + fetchCompletions;
//
//
//Check we got a good response from ChatGPT
if (fetchCompletions.get("responseCode") == 200) {
// Grab the answer from Chat GPT
answer = fetchCompletions.get("responseText").get("choices").getJSON("text");
//
//
//Put the answer into the response map which is what we'll return to the user
response.put("text", answer);

}
else if (fetchCompletions.get("responseCode") == 429)
{
response = { "text": "Oops! I can't help with this. Try asking something else :wink:" };
}
//
//
// Trigger the response back to the user.
return response;


27 Second Gif... use the extra 3 seconds to set your own OpenAI "token" before you paste the code (get your token here)

 


Some FAQ:

Will this allow users to subscribe to a bot and ask it questions and get answers?
Yes but it is not the current ChatGTP version that everyone is raving about. It's the ChatGPT-3 Da-Vinci model which is excellent but not on the same level as ChatGTP-4 which is still in research mode and does not yet have an API connection.

Will it remember my previous questions?
It generally depends on how you phrase the questions and give the context. It's not on the same level as ChatGPT-4.

I asked it a question but it does not give me a great answer, why?
How you enter your "prompt" (question) is the important part. Generally the more context and instruction you give the better the answer. Google or YouTube  "ChatGPT Prompt Design" and you'll be an expert in no time. 

    Access your files securely from anywhere







                            Zoho Developer Community




                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                  • Ask the Experts



                                                            • Sticky Posts

                                                            • Automating Employee Birthday Notifications in Zoho Cliq

                                                              Have you ever missed a birthday and felt like the office Grinch? Fear not, the Cliq Developer Platform has got your back! With Zoho Cliq's Schedulers, you can be the office party-cipant who never forgets a single cake, balloon, or awkward rendition of
                                                            • Customer payment alerts in Zoho Cliq

                                                              For businesses that depend on cash flow, payment updates are essential for operational decision-making and go beyond simple accounting entries. The sales team needs to be notified when invoices are cleared so that upcoming orders can be released. In contrast,
                                                            • Accelerate Github code reviews with Zoho Cliq Platform's link handlers

                                                              Code reviews are critical, and they can get buried in conversations or lost when using multiple tools. With the Cliq Platform's link handlers, let's transform shared Github pull request links into interactive, real-time code reviews on channels. Share
                                                            • App Spotlight : PagerDuty for Zoho Cliq

                                                              App Spotlight brings you hand-picked apps to enhance the power of your Zoho apps and tools. Visit the Zoho Marketplace to explore all of our apps, integrations, and extensions. In today's fast-paced world, seizing every moment is essential for operational
                                                            • Automate your status with Cliq Schedulers

                                                              Imagine enjoying your favorite homemade meal during a peaceful lunch break, when suddenly there's a PING! A notification pops up and ruins your moment of zen. Even worse, you might be in a vital product development sprint, only to be derailed by a "quick


                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner







                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources

                                                                                              Zoho Writer

                                                                                              Get Started. Write Away!

                                                                                              Writer is a powerful online word processor, designed for collaborative work.

                                                                                                Zoho CRM コンテンツ



                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方