OpenAI Alert! Plug Sample #11 - Next-generation chatbots, Zobot + ChatGPT Assistant

OpenAI Alert! Plug Sample #11 - Next-generation chatbots, Zobot + ChatGPT Assistant

Hi Everyone!
We have great news for all AI enthusiasts and ChatGPT users! The much anticipated Zobot integration with ChatGPT Assistant is now available with Plugs. 

OpenAI has introduced 'ChatGPT Assistants' to customize GPT models as per your requirement. These Assistants work based on your data, instruction, files, functions and more, making it more susceptible to your needs. With Assistant, your SalesIQ bot can be more powereful than ever,  providing contextual assistance to your audience with data specifically exclusive for your business. 

Please ensure to have a ChatGPT Assistant in your OpenAI Platform to use this Plug.

Here's what the SalesIQ chatbot-Assistant brings to the table:
  • Targeted Responses: Your bot will be entirely specific to your business, ensuring a tailored experience for your audience, rather than relying on global data.
  • Omnichannel Availability: Bot works across all channels, including your mobile app, Website, Facebook, Instagram, WhatsApp, Telegram, and LINE.
  • Human-like conversations:  Engage your audience with natural, engaging interactions that feel human.
  • Always-on availability:  Provide 24/7 customer support with your bot, ready to engage with users anytime.


In this post, we will learn how to create a plug and connect your trained ChatGPT Assistant with your bot. 
Are you new to SalesIQ? Click here to know about SalesIQ's chatbots and plugs

Plug Overview

The ChatGPT Assistant functions based on threads. Initially, you create a thread, add a message to it, and run the message to receive the Assistant's response. So, to integrate ChatGPT Assistant with the Codeless bot builder, we need two plugs.
  • Plug 1 - To create a thread (thread ID) using OpenAI API keys.
  • Plug 2 - To add a message to the thread using the thread ID, create a run and get the ChatGPT assistance's response. 


Help guide to know more about how ChatGPT assistant works

How to build this Plug?

Step 1 - [Plug 1] Creating a thread for the visitor/user 
  • On your SalesIQ dashboard, navigate to Settings > Developers > Plugs > click on Add.
  • Provide your plug a name, and description, and select the Platform as SalesIQ Scripts. Here, we call this plug as ChatGPTAssistantsCreateThread
  • The first step in building the plug is defining the parameters. This plug aims to create a thread and get the thread ID as output. So, only the output parameter (threadID) is needed here. 


Copy the code below and paste it into your plug builder. Then, make the following changes. 
  • In line #2, replace your api_key (Navigate to the OpenAI developer section and click on API keys to create a new one)
  1. //ChatGPT api key
  2. api_key = "paste-your-api_key";
  3. //Header parameters
  4. headers = Map();
  5. headers.put("Authorization","Bearer " + api_key);
  6. headers.put("Content-Type","application/json");
  7. headers.put("OpenAI-Beta","assistants=v2");
  8. //This param is needed to use the V2 assistant apis
  9. // The following webhook will create a thread and return the thread id
  10. response = invokeurl
  11. [
  12. url :"https://api.openai.com/v1/threads"
  13. type :POST
  14. headers:headers
  15. ];
  16. response_json = response.toMap();
  17. thread_id = response_json.get("id");
  18. response.put("threadID",thread_id);
  19. return response;
  • Then, click Save, preview the plug and Publish it. 
Reference:  OpenAI's Create a thread API

Step 2 - [Plug 2] Add a message to thread and get response 
  • From the previous plug, we will get the thread ID as output. 
  • Create a new plug, here we call this plug as ChatGPTAssistantsCreateRuns.
  • Pass the thread ID and the user/visitor input as input parameters. 
  • Once the plug is executed, we will get the ChatGPT Assistance's response, which is the output parameter. 
Input Parameters
  • Name: threadID | Type: String
  • Name: userInput | Type: String
Output Parameters
  • Name: assistantReply | Type: String


Copy the code below and paste it into your plug builder. Then, make the following changes. 
  • In line #2, replace your api_key (Navigate to the OpenAI developer section and click on API keys to create a new one.)
  • In line #3, replace your chatGPT_assistant_id (Navigate to the OpenAI developer scetion > Assistants > choose your Assistant and copy the Assistance ID.


  1. //ChatGPT api key
  2. api_key = "paste-your-api_key";
  3. chatGPT_assistant_id = "asst_4DuWZxC0RNagq0b8pnml4ZPf";
  4. //Header parameters
  5. headers = Map();
  6. headers.put("Authorization","Bearer " + api_key);
  7. headers.put("Content-Type","application/json");
  8. headers.put("OpenAI-Beta","assistants=v2");
  9. //Get the thread ID from the plug input parameters
  10. thread_id = session.get("threadID").get("value");
  11. user_input = session.get("userInput").get("value");
  12. info thread_id;
  13. info user_input;
  14. // Messages API call
  15. requestBody = Map();
  16. requestBody.put("role","user");
  17. requestBody.put("content",user_input);
  18. jsonRequestBody = requestBody.toString();
  19. // The following webhook posts a message to the conversation thread
  20. response = invokeurl
  21. [
  22. url :"https://api.openai.com/v1/threads/" + thread_id + "/messages"
  23. type :POST
  24. parameters:jsonRequestBody
  25. headers:headers
  26. ];
  27. info response;
  28. // Runs API call
  29. requestBody = Map();
  30. requestBody.put("assistant_id",chatGPT_assistant_id);
  31. jsonRequestBody = requestBody.toString();
  32. // The following runs the thread which inturn generates a response once the thread is completed
  33. response = invokeurl
  34. [
  35. url :"https://api.openai.com/v1/threads/" + thread_id + "/runs"
  36. type :POST
  37. parameters:jsonRequestBody
  38. headers:headers
  39. ];
  40. response_json = response.toMap();
  41. run_id = response_json.get("id");
  42. run_status = "queued";
  43. retry_count = {1,2,3,4,5};
  44. for each  retry in retry_count
  45. {
  46. if(run_status != "completed")
  47. {
  48. // The above executed run takes few seconds to complete. Hence a considerable time has to be left before the run is completed and the messages are fetched from the thread can be fetched. Here we wait for 3 seconds assuming the run gets complete within 3 seconds
  49. getUrl("https://httpstat.us/200?sleep=3000");
  50. response = invokeurl
  51. [
  52. url :"https://api.openai.com/v1/threads/" + thread_id + "/runs/" + run_id
  53. type :GET
  54. headers:headers
  55. ];
  56. response_json = response.toMap();
  57. run_status = response_json.get("status");
  58. }
  59. }
  60. // The following webhook fetches the messages from the thread
  61. getmsg_url = "https://api.openai.com/v1/threads/" + thread_id + "/messages";
  62. response = invokeurl
  63. [
  64. url :getmsg_url
  65. type :GET
  66. headers:headers
  67. ];
  68. info response;
  69. response_json = response.toMap();
  70. // Getting the last message from the thread messages list which is the assistant response for the user input.
  71. assistant_response = response_json.get("data").get("0").get("content").get("0").get("text").get("value");
  72. info assistant_response;
  73. response = Map();
  74. response.put("assistantReply",assistant_response);
  75. return response;
  • Then, click Save, preview the plug and Publish it. 

Step 3 - Adding plugs to the Codeless bot builder
  • Navigate to Settings > Bot > Add, provide the necessary information, and select Codeless Bot as the bot platform. You can also open an existing bot.
  • Next, click on Plugs under Action cards, select the first plug (ChatGPTAssistantsCreateThread), and provide a name to save the output (thread_id).

  • Use the visitor fields card, click save in bot context, and provide a name to store the visit
  • Then, select Plug 2 (ChatGPTAssistantsCreateRuns) and pass the value for the parameters
    • thread_id (Input) - The output of the previous Plug
    • user_input (Input) - The visitor's question/input from visitor fields card. 
    • assistant_reply (Output) - The final response from the ChatGPT assistance. 

  • Finally, use any response/input card to display the response to the visitor by typing the % to get the context variable (%assistant_reply%) in the message text box. Here, the button card is used along with the follow-up actions. 
Note: 
  • The ChatGPT Assistant APIs are still in beta, so it's better to have a fallback flow in the bot until they are stable. 
  • Manage the plug failure instances within the plug failure leg by directing your users to operators using the "Forward to Operator" card or use the "Busy response" card to get the user's question, put them on the missed chats. Additionally, you can also "Send Email" card to notify yourself about the user's inquiry. 

  • The buttons, "I've another question", is used to get next question from the visitor. Use a Go To card and route it to visitor fields card to ask next question. 

I hope this was helpful. Please feel free to comment if you have any questions. I'll be happy to help you. 

Best regards
Sasidar Thandapani

    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

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

                            Zoho CRM コンテンツ






                              ご検討中の方

                                • Recent Topics

                                • Populate a Related List Item based on a Stage

                                  I would like to know if I can populate a CLOSED DEAL section in a contact that populates only when a Deal (something in the Deal Module) is listed as Closed - Won. I'd like another section that is just called deals, which shows me all other deals that
                                • Being able to draw inside a module ?

                                  I was wondering if anyone know of a solution for this request. We would like to be able to draw directly from one module in the CRM and have it attached to that record. Here is an example. Paul would go to the customer once he as done the measuring, he
                                • Holidays

                                  Hi; For defining Holidays, you need to add logic to handle the year as well as the month & day. We need to be able to enter Holidays for the next year. I need to add a holiday for January 2, 2017, but I can't until January 1st, which is a Sunday and we
                                • Delete a department or category

                                  How do I delete a Department?  Also, how do I delete a Category? This is pretty basic stuff here and it's impossible to find.
                                • Remove or hide default views

                                  I'm looking to only have the views pertinent to my organization.  Is there a way to show only my custom views (or separate them to a different area or something)? If not, this should be a feature as switching from Zendesk we had this option...
                                • Analytics Module: Can you move items from one dashboard to another?

                                  Is there a way to move items from one dashboard to another? I want to rearrange my dashboard now that I know what i'm doing but i don't want to remake my various widgets? Edit: Hey Zoho, This would be a good feature: to be able to move/copy widgets to
                                • Copy Widget to another Dashboard

                                  I can see the option to clone a widget to the same dashboard but is it possible to copy it to another dashboard?
                                • Introducing Record Summary: smarter insights at your fingertips

                                  Hello everyone, Building on the recent launch of Zoho's in-house Zia Large Language Model (Zia LLM)—a major milestone in Zoho CRM’s AI capabilities—we’re excited to introduce the Record Summary feature. This powerful addition makes use of Zia LLM to simplify
                                • Suppress "spreadsheet will not be saved" message on published sheet

                                  I have published a sheet and have one column on that sheet that the user can edit (a dropdown picklist where the user can select the status for each line). Is there a way to suppress the Zoho Sheet message "Any changes made to this published spreadsheet
                                • Missing "Email Authentication" tab

                                  Backstage is alerting users about "Unauthenticated Domains" with a large prompt in the backend. It adds a link to learn more. On this tutorial page, it shows where to find the "Email Authentication" tab in this screenshot. However, in our Backstage, that
                                • Show item Cost value on Item screen

                                  The Item screen shows Accounting Stock and Physical Stock. It would be very helpful if value information could be displayed here as well, for instance Cost Price. Currently, to find the Cost Price (as used for inventory valuations) from inside the item
                                • Integration with Moodle

                                  Greetings, I hope find all doing well and safe. I've recently returned to using Zoho Flow after a break and was hoping to connect my WooCommerce store with Moodle, the world's most widely used learning management system. My goal was to automatically enroll
                                • How to Record Loan with interest

                                  I have received loans from friend he give me like 2 loans so far one is one year repayment and one short, how to properly record his payment, and repayment and give him statement  for each loan he give me 
                                • Task status - completed - other options

                                  I have a dumb question I know i can make custom statuses for the tasks - but is there anyway to make additional "completed" statuses like for instance if i have a task "call back customer" and i leave a vm for them to call back marking it "completed -
                                • Task module and related-to field

                                  In modules other than the Task Module I can add several lookup fields to provide a variety of relationships. In the Task module lookup fields are not available. There is only one "related to" field which I want to use for Company. But I want to relate
                                • Add Lookup Field in Tasks Module

                                  Hello, I have a need to add a Lookup field in addition to the ones that are already there in the Tasks module. I've seen this thread and so understand that the reason lookup fields may not be part of it is that there are already links to the tables (https://help.zoho.com/portal/en/community/topic/custom-fields-on-task-module).
                                • migrating from Zoho Invoices (CRM) to Zoho Books

                                  Good day, I was wondering if there was a easy way to migrate all the quotes and invoices from Zoho Invoices CRM to Zoho Books. We plan to move to using Zoho Books in a few weeks and would like to have all the quotes and invoices from the past 3 years
                                • Zoho MA and Custom Module

                                  I am trying to create a sync between Markting Automation and Zoho CRM. I am mapping a custom module from the CRM. The custom module has email field mobile phone field However I cannot finish the integration since the system keeps asking me for email or
                                • When is partial reimbursement going to be launched?

                                  Hi there. I saw somewhere that the partial reimbursement feature is in the work. What is the update and ETA of that? Our clients and prospects have been asking us and we agree that that is an important feature to have.
                                • Year-End Wrap: Declutter Your Inbox Using Email Filters

                                  Ping!—an email drops in. And another. And another! It's finally that time of the year when your inbox will be bursting with messages from team members, clients, and marketing agents, leaving you feeling overwhelmed and distracted. Sounds familiar? Now
                                • Unified Notes View For Seamless Collaboration

                                  To facilitate better coordination among different departments and team members, the notes added to a record can now be accessed in all its associated records. With this, team members, from customer service representatives to field technicians, can easily
                                • Q4 Europe In-person Zoho User Group Meetup: Streamlining Your Business Processes & Introduction to Zoho CRM for Everyone

                                  Hello Zoho Community, We are excited to announce our upcoming Zoho User Group meetup in Europe! This session is designed to help you streamline your business processes using Zoho CRM, with a special focus on enhancing customer interactions and leveraging
                                • Formula fields - Request for dynamic recalculation / proper implementation

                                  Hi Guys, I have a big problem with Zoho formula fields. They don't recalculate each time the record is viewed - only when a record is edited. Formula fields should be updated dynamically each time a record is retrieved. As an example: I have a formula
                                • Items attribute questions

                                  Many of my items have attributes, such as size and color. How can I add new fields to the "New Items" screen to capture that in my Purchase Orders, Items, and Sales Order pages? I only see these attribute fields when adding an Item Group. Also, on the
                                • Organize and Track Phases with Phase Custom Views

                                  Phase Custom Views let you filter and display phases based on specific criteria. This helps you focus on what’s most relevant for you and your team. Filter phases using criteria such as budget, status, and more. Share views with specific users or teams
                                • Record Asset Received as Payment

                                  How exactly would you account for this in books? For example, I receive a mini computer for a review and I get to keep it after the video is published. Would debit my normal asset account (e.g. Computers) and credit an income account (e.g. Other Income).
                                • Invoice Line Item Report

                                  Is it possible to run an 'Invoice Line Item Report'? The 'Invoice Details Report' shows one row per invoice. I would like one row per Invoice Line Item.
                                • Transform Your Customer Support with AI-Powered Chatbots in Zoho SalesIQ

                                  Ever wondered how some companies seem to have superhuman customer support? Let's uncover their secret! In the digital age, customer expectations are skyrocketing. Did you know that according to McKinsey, 75% of consumers expect a response within five
                                • Progressive Invoicing

                                  Progressing invoicing is needed for many industries. It would be great to see it implemented into Zoho Books as well. Set up and send progress invoices in QuickBooks Desktop (intuit.com)
                                • Client Script - mapping data from different module

                                  Dear ZOHO Team Firstly I need to describe the need - I need to have data from Contacts module based on lookup field - the 5 map limit is not enough for me because I have almost 20 fields to copy So I have decided to make a Customer Script - and from unknown
                                • DORA compliance

                                  For DORA (Digital Operational Resilience Act) compliance, I’ll want to check if Zoho provides specific features or policies aligned with DORA requirements, particularly for managing ICT risk, incident reporting, and ensuring operational resilience in
                                • Files Uploaded to Zoho WorkDrive Not Being Indexed by Search Engines

                                  Hello, I have noticed that the files I upload to Zoho WorkDrive are not being indexed by search engines, including Google. I’d like to understand why this might be happening and what steps I can take to resolve it. Here are the details of my issue: File
                                • Zoho Creator Upcoming Updates - December 2024

                                  Hi all, We're excited to be back with the latest updates and developments on the Creator platform. Here's what we're going over this month: Deluge AI assistance Rapid error messages in Deluge editor QR code & barcode generator Expandable RTF and multi
                                • Customer can't comment on SO or Invoice

                                  Hi I just saw that my customers are not able to submit a comment either on invoices or sales order. What happens if my customer hits submit is just nothing. only a red line appears on top of the page which probalby indicates an error. I'm not able to
                                • Zoho Creator customer portal limitation | Zoho One

                                  I'm asking you all for any feedback as to the logic or reasoning behind drastically limiting portal users when Zoho already meters based on number of records. I'm a single-seat, Zoho One Enterprise license holder. If my portal users are going to add records, wouldn't that increase revenue for Zoho as that is how Creator is monetized? Why limit my customer portal to only THREE external users when more users would equate to more records being entered into the database?!? (See help ticket reply below.)
                                • See Calendar When Creating Meetings On Record Page

                                  It would be a great user experience to see you calendar while you are creating a meeting on a record page. Here is how I imagine it could look:
                                • Saved filters, layout rule support, related list quick navigation, and more

                                  Hello Everyone, We're excited to share some new features and enhancements in the Zoho CRM iOS and Android apps that will improve your mobile experience. These updates will make your CRM journey more efficient and user-friendly. Here's a look at what's
                                • Power of Automation: Automatically send an email to all portal users with today's list of Open tasks.

                                  Hello Everyone, A Custom Function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as to when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it. Requirement:-
                                • Introduction of Robotics Process Automation in Zoho products

                                  It will be great if Zoho can start advancing from automation to robotics process automation. For a start, it can be started with smart document understanding. Provide OCR engines Google cloud, Microsoft Azure Computer vision OCR, Microsoft OCR, Omnipage
                                • Lock a custom field on a deal record but keep all other fields editable?

                                  I have a custom field, which auto-populates a job number upon converting a lead to a deal but the automation breaks if someone accidentally edits that field. I want to lock that field but keep all other fields open. Is this possible? I've tried through
                                • Next Page