header.phone_number boris@borisbot.com
integration
marketing
gpt
In this article, we'll discuss how to set up ChatGPT (OpenAI) integration with a chatbot. 

Integration with GPT allows you to connect OpenAI's artificial intelligence to your bot.

To set up the integration in the builder, you need to obtain an API key and your organization's information at platform.openai.com.

Please note: platform.openai.com is a separate platform from ChatGPT. If you're simply using ChatGPT in a browser or app, that's not enough — you should register directly at platform.openai.com.

How to get an API key

1. Register on the OpenAI platform.
Go to platform.openai.com and create an account.
2. Create an organization.
Specify a name and role. Click Create Organization.
3. Generate an API key.
Specify a name for the key and, if desired, a project name. Click Generate API Key.
Your key will then appear. Click Copy. Save it immediately, for example, in your notes. It will be impossible to view it again.
Find your Organization ID.

To find your organization ID, click the ⚙️ icon in the upper right corner → SettingsGeneral.

How to add data to the constructor

1. Log in to your project in the designer.
2. Go to SettingsIntegrationsGPT.
3. Select the connection type — openai.
4. Paste your API key and Organization ID.
5. Click Save.

This step connects BuddyBot to your OpenAI account. Without it, GPT blocks won't work.

How to work with GPT blocks

There are two types of GPT blocks on the platform:

Chat with the Internet database — the model accesses information from the Internet like a regular ChatGPT.
GPT assistant (based on your database) — works only with documents uploaded by you: instructions, FAQ, materials about the company, products or services.
Let's analyze the configuration of each block. 

Chat with the Internet database
Click on the block to open the settings menu. 

Select a GPT model
The models have different features and prices. All models can understand and also generate natural language or code. ChatGPT-4 is the latest neural network model that better understands context and distinguishes nuances, which gives more accurate and logical answers. Plus, it takes into account a larger number of tokens. 
A detailed description of all models can be found here

Set the temperature
Temperature is the degree of GPT improvisation. It takes a value from 0.1 to 1.0. The higher the value, the more abstract the GPT response will be. Low values make the answers more detailed, higher values make them more random. 

Specify the number of tokens
Token is a part of a word. Before the API processes the request, the input data is split into tokens. For English text, 1 token is about 4 characters or 3/3 of a word; 100 tokens is about 75 words. To check the number of tokens, use Tokenizer.  

Depending on the model used, requests may use a different number of tokens. More information about tokens can be found here

The maximum number of tokens you specify limits the length of the response, but the response you receive is not necessarily that long. Depending on the content of the request, it may be shorter.

Add basic setup
Basic setup is a description based on which the bot generates responses. The correct phrases embedded in the installation will help to achieve accurate and contextual responses from AI. 

1. Write specifically and clearly. Provide all the introductory information, describe the problem, the purpose of the bot, the context, and the specifics that you consider important. Use simple language, avoiding ambiguity. 
2. Use examples to make it clear exactly what you want. For example, add examples of headings for articles in the style of which you need the text. 
3. Specify the role and personalize the bot. For example, "you're a lawyer who specializes in civil law." Describe what qualities he possesses and what tone he should use in communication.  

After testing the bot, adjust the installation text until you get the necessary answers.   

You can find out more about the instructions for GPT here.
Assistant

Go back to the OpenAI platform, open the Assistant section and create an assistant:  
1. Click Create
2. Enter the name of the assistant
3. In the Instructions field, describe what the assistant should do (for more information about it, see above) 
4. Select a model 
5. Turn on the File search tool and upload the file with your knowledge base.
Go to the constructor and fill in the fields in the Settings of the GPT Assistant block. 
1. Select the created assistant. 
The following settings are optional.  
2. Specify the Thread ID. Thread is a sequence of messages combined by a context. The GPT block generates a thread in the %answer_x.thread_id% variable. If you specify a thread in the settings, the bot maintains the context of the messages. 
3. Add the instructions. This is a description of what an assistant should do. You can copy the instructions listed on OpenAI.

Examples of bots with GPT

We have collected ready-made bot templates that can be adapted to your script or just find out how the bot works inside. 

📚 Knowledge base with GPT (GPT assistant). The bot answers questions about the work of the constructor, saves requests in the system and directs them according to different scripts.
🕵️ A bot for group moderation on Telegram. It recognizes and deletes unwanted chat messages. 
💡 Testing students with AI. The GPT bot checks and evaluates the knowledge.
👩🏻‍💻 Competency interview with AI. The GPT bot tests the applicant's knowledge: it asks questions and evaluates the result.

How to use the template? 
1. Register on the platform 
2. Copy the template to your project 
3. Set up the ChatGPT integration and the bot script