10.01.2024
246

Analyze emails with OpenAI (ChatGPT)

Analyze emails with OpenAI (ChatGPT)

Integration with OpenAI (ChatGPT) is implemented as a separate AI block (ChatGPT) that can be placed between the Data Source and Data Destination. This will allow you to create a query based on data from the Data Source and pass data from OpenAI (ChatGPT) to the Data Ingest fields. This way you can automatically receive data from OpenAI (ChatGPT) and transfer it to the services and systems that you use.

The function allows you to analyze data from the Data Source using OpenAI (ChatGPT) and transfer the query result to the Data Destination.

Navigation:

Connecting Gmail as a Data Source:

1. What data can you get from Gmail?
2. How to connect your Gmail account to ApiX-Drive?
3. Select a label.
4. An example of data that will be transferred from Gmail.

OpenAI (ChatGPT) connection:

1. What data can be obtained from OpenAI (ChatGPT)?
2. How to connect your OpenAI (ChatGPT) account to ApiX-Drive?
3. How to configure data search in OpenAI (ChatGPT) in the selected action?
4. An example of data that will be transferred from OpenAI (ChatGPT).

Setting up data transfer in Telegram:
1. What will integration with Telegram do?
2. How to connect a Telegram account to ApiX-Drive?
3. How to set up data transfer to Telegram in the selected action?
4. An example of the data will be sent to your Telegram.
5. Auto-update and update interval.

Setting up Data SOURCE: Gmail

Let's look at how the function of requesting data from OpenAI (ChatGPT) and transmitting the result to Telegram works.

In this example, we are looking at retrieving data from Gmail, but you can also use other email services.

First, you need to create a new connection.

Setting up analyze emails with OpenAI (ChatGPT) | Create connection

Select the system as the Data Source. In this case, you must specify Gmail.

Setting up analyze emails with OpenAI (ChatGPT) | Selecting a Data Source System

Next, you need to specify the action "Get EMAIL (new)".

Setting up analyze emails with OpenAI (ChatGPT) | Action selection

The next step is to select the Gmail account from which will get the emails.

If there are no accounts connected to the system, click "Connect account".  

Setting up analyze emails with OpenAI (ChatGPT) | Account connection

Select which account you want to connect to ApiX-Drive and provide all permissions to work with this account.

Setting up analyze emails with OpenAI (ChatGPT) | Account connection
Setting up analyze emails with OpenAI (ChatGPT) | Account connection

When the connected account is displayed in the "active accounts" list, select it.

Attention! If your account is in the "inactive accounts" list, check your access to this account!

Setting up analyze emails with OpenAI (ChatGPT) | Account selection

Specify the Labels of your e-mail from which you want to get the messages.

Setting up analyze emails with OpenAI (ChatGPT) | Selecting Labels

If necessary, you can set up a Data Filter, or click "Continue" to skip this step.

To find out how to setup the Data Filter, follow the link: https://apix-drive.com/en/help/data-filter

Setting up analyze emails with OpenAI (ChatGPT) | Data filter

Now you can see the test data for one of your emails.

If you want to update the test data - click "Load test data from Gmail".

If you want to change the settings - click "Edit" and you will go back one step.

If everything suits you, click "Next".  

Setting up analyze emails with OpenAI (ChatGPT) | Test data
Setting up analyze emails with OpenAI (ChatGPT) | Test data

Now we connect the additional OpenAI block (ChatGPT). To do this, click on “+” and select “AI (GPT-Chat)” from the list.

Setting up analyze emails with OpenAI (ChatGPT) | Selecting a OpenAI system

Setting up OpenAI (ChatGPT)

Select "OpenAI (ChatGPT)" as the system in which the search will be performed.

Setting up analyze emails with OpenAI (ChatGPT) | System selection

Next, you need to specify the action; for this task we recommend using GPT-4 or GPT-3.5. Select, for example, "Send PROMPT (GPT-4)".

Setting up analyze emails with OpenAI (ChatGPT) | Action selection

- Send PROMPT (GPT-4) is a large multi-modal model that can solve complex problems with greater accuracy.
(Available in the API for paid OpenAI users only!)
- Send PROMPT (GPT-3.5) - these models can understand and generate natural language or code. The most functional and economical model of the GPT-3.5 family is gpt-3.5-turbo.

The next step is to select an OpenAI (ChatGPT) account.

If there are no logins connected to the ApiX-Drive system, click “Connect account”.

Setting up analyze emails with OpenAI (ChatGPT) | Account conection

Enter the API key, which is located in the settings of your OpenAI (ChatGPT) personal account.

Go to your OpenAI (ChatGPT) account, click on the “Personal” tab in the upper right corner, then go to the “View API keys” section and click “Create new secret key”. Copy the API key and paste it into the appropriate field in the account connection window in the ApiX-Drive system.

If your OpenAI (ChatGPT) account belongs to multiple organizations, you must also provide the Organization ID. To do this, go to "Settings" and copy the Organization ID.

Click "Save" and select the connected OpenAI (ChatGPT) account from the drop-down list.  

Setting up analyze emails with OpenAI (ChatGPT) | Account conection
Setting up analyze emails with OpenAI (ChatGPT) | Account conection
Setting up analyze emails with OpenAI (ChatGPT) | Account conection
Setting up analyze emails with OpenAI (ChatGPT) | Account conection

When the connected account appears in the "active accounts" list, select it for further work.

Attention! If your account is on the "inactive accounts" list, check your access to this login!

Setting up analyze emails with OpenAI (ChatGPT) | Account selection


Now you need to select OpenAI Model. The choice of model depends on your task.

GPT-4 models can solve complex problems with greater accuracy than previous models. GPT-4 is optimized for chat and has JSON mode. Models are suitable for writing code, analyzing and writing texts, answering questions about the knowledge base. These models also do a better job of translating into other languages than previous models.
More details about the models:
GPT-4

GPT-3.5 models can understand and generate natural language or code. Functional and economically optimal models. Suitable for traditional tasks such as analysis or generation of text and code, translation of texts.

More details about the models:

GPT-3.5

In this case, select, for example, "GPT-4 Turbo with Vision (128k)".

Setting up analyze emails with OpenAI (ChatGPT) | Setting up OpenAI (ChatGPT)

- Prompt - in this field you need to assign which variable of the Data Source table contains the data for which the query will be made on the OpenAI server (ChatGPT), in our case, this is column “A”.
- Maximum tokens - is the number of words up to which generation will continue in OpenAI. 1,000 tokens - 750 words.
-Presence penalty - This parameter is used to encourage the model to include a variety of tokens in the generated text. This is the value that is subtracted from the log likelihood of the token each time it is generated. A higher Presence Penalty value will cause the model to be more likely to generate tokens that were not already included in the generated text.
-Frequency penalty - this parameter is used to prevent the model from repeating the same words or phrases too often in the generated text. This is the value that is added to the log likelihood of the token each time it appears in the generated text. A higher Frequency Penalty value will cause the model to be more conservative in its use of duplicate tokens.
-Temperature - can range from 0 to 2. Higher values such as 0.8 will make the output more random, while lower values such as 0.2 will make it more focused and deterministic.  

Setting up analyze emails with OpenAI (ChatGPT) | Assigning fields

Now you see test data for your request. You can pass this data to your Data Destination block.

If test data does not appear automatically, click "Search in OpenAI (ChatGPT)".

If you are not satisfied with something, click “Edit”, go back a step and change the search field settings.  

Setting up analyze emails with OpenAI (ChatGPT) | Test data
Setting up analyze emails with OpenAI (ChatGPT) | Test data

This completes the OpenAI (ChatGPT) data setup!

Now we can start setting up Telegram as a Data Destination system.

To do this, click "Add Data Destination".

Setting up analyze emails with OpenAI (ChatGPT) | Selecting a data destination system

Setting up Data Destination: Telegram

You can use various services to obtain data, for example, create a task, lead or card in project management services. Send notifications to instant messengers and much more.

Select the system as Data Destination. In this case, you must specify Telegram.

Setting up analyze emails with OpenAI (ChatGPT) | System selection

Next, you need to specify the action "Send MESSAGE".
You can add our bot and receive notifications from it about important events from other systems in your Telegram or group.

Setting up analyze emails with OpenAI (ChatGPT) | Action selection

The next step is to select the Telegram account from which will get the data.
If there are no accounts connected to the system, click "Connect account".  

Setting up analyze emails with OpenAI (ChatGPT) | Account connection

In the window that appears, enter the name of the account and click "Continue".

Setting up analyze emails with OpenAI (ChatGPT) | Connection setup

Next, a new window will open in which you need to copy the data in the "A line for connecting a Telegram bot" field.
Then close this window, reload the page and select the created account.
Now you need to go to your Telegram application.  

Setting up analyze emails with OpenAI (ChatGPT) | Connection setup

In your Telegram application, enter @apix_drive_bot in the search bar.
Click on the bot profile and click "Start".

Setting up analyze emails with OpenAI (ChatGPT) | Connection setup

Send a message to the bot with the connection line that was copied from the ApiX-Drive system.

Wait for a response message about a successful connection to the system.

After that, return to the ApiX-Drive system and continue with the configuration.

Setting up analyze emails with OpenAI (ChatGPT) | Connection setup
Setting up analyze emails with OpenAI (ChatGPT) | Connection setup

Note!
If you want messages to come to the channel or group, you need to add our bot to the group or channel, run it there and configure it. As a result, the group or channel should receive an answer that the bot is connected successfully.

If you have previously connected our bot to yourself, and now you want to connect it to a group or channel, you need to perform the following algorithm:
1. You need to disable our bot, clear the entire history and completely delete the dialogue with the bot.
2. In our system, go to the Accounts - Messengers - Telegram and delete all created accounts.
3. Go to your connection in the Data Destination to the "Access" stage and create a new account.
4. According to the help you need to re-configure Telegram, only this time first you need to create a group or channel, add our bot, and send a string with a connection. After that, send the test data to Telegram and check that getting.

Select a Telegram account and click "Continue".

Setting up analyze emails with OpenAI (ChatGPT) | Account selection

Now, you need to compose a message from the data that will be sent to the Telegram bot.

In order to add a variable, click on the field "Message" and select the desired variable from the drop-down list. If necessary, you can write the data manually.

When the message is generated, click "Continue".

Setting up analyze emails with OpenAI (ChatGPT) | Assigning field

Thus, the OpenAI (ChatGPT) block takes the field in the Data Source in which you have written the request text, queries the OpenAI (ChatGPT) server for the result of this request and transmits this data to the Data Destination field in the form of a message.

Now you can see the test data of what your message will look like.

To check the correctness of the settings - click "Send test data to Telegram" and go to your Telegram to check the result.

If everything suits you, click "Next" for further settings.

Setting up analyze emails with OpenAI (ChatGPT) | Test data

Note!
If the test message does not arrive or there is no response that the bot is successfully connected, check what settings you used to launch the bot (Accesses - Messengers - Telegram), and which Telegram account (if there are several) is selected at the Access stage. If this does not help, follow the steps below:
1. You need to disable our bot, clear the entire history and completely delete the dialogue with the bot.
2. In our system, go to the Access - Messengers - Telegram section and delete all created accounts.
3. Go to your connection in the Data Destination block at the Access stage and create a new account.
4. According to the help, configure Telegram again and send test data to Telegram.

We would like to draw your attention!
When transferring data to Telegram, there is a limit on sending messages to the bot - 1 message every 3 seconds. For example, if you want to transfer 10 emails, it will take 30 seconds.

This completes the Data Destination system setup!
Now you can start choosing the update interval and enabling auto-update.
To do this, click "Enable update".      

Setting up analyze emails with OpenAI (ChatGPT) | Enable auto-update

On the main screen, click on the gear icon to select the required update interval or set up scheduled launch. To start the connection by time, select scheduled start and specify the desired time for the connection update to fire, or add several options at once when you need the connection to fire.

Attention! In order for the scheduled run to work at the specified time, the interval between the current time and the specified time must be more than 5 minutes. For example, you select the time 12:10 and the current time is 12:08 - in this case, the automatic update of the connection will occur at 12:10 the next day. If you select the time 12:20 and the current time is 12:13 - the auto-update of the connection will work today and then every day at 12:20.

To make the current connection transmit data only after another connection, check the box "Update connection only after start other connection" and specify the connection after which the current connection will be started.   

Setting up analyze emails with OpenAI (ChatGPT) | Update interval
Setting up analyze emails with OpenAI (ChatGPT) | Update Priority

To enable auto-update, switch the slider to the position as shown in the picture.

To force the connection, click on the arrow icon.    

Setting up analyze emails with OpenAI (ChatGPT) | Enable auto-update

This completes the setup of OpenAI (ChatGPT)! Everything is quite simple!

Now don't worry, ApiX-Drive will do everything on its own!