Connect OpenAI to Albato and integrate with Telegram

OpenAI: Automate with Albato
OpenAI
·
12/28/2022
·
5 min. read

OpenAI is an AI research and deployment company. Their mission is to ensure that artificial general intelligence benefits all of humanity.

GPT-3 (Generative Pre-trained Transformer) is the third generation of artificial intelligence developed by OpenAI. It is created to generate text and code and can be used for various tasks, such as text analysis, SEO, SMM, categorization, etc.

There are four main models that can perform different purposes: analyze and respond to complex queries, optimize texts for SEO and SMM, convert texts into tables, help with brainstorming, edit and translate texts, process code and mathematical problems, and conduct a dialogue on any topics.

To customize OpenAI to your needs, select a model and add some directives. For example, you can add an answer tone, specify language, limit questions or topics, provide additional information, and define the format you want to receive answers.

Connect OpenAI (GPT-3) to Albato and set up integrations with other apps and systems to give users even more advanced, automated responses to help them solve various additional tasks.

Integration options

Actions:

  • Change the phrase
  • Get phrase completion
  • Image generation

How to connect OpenAI to Albato

Before configuring automations with OpenAI, connect the service to Albato.

To do this, go to the Apps section in your Albato account and click the Add a connection button.

2022-10-10_11-17-14.png

Select the OpenAI from the drop-down list or use the search bar.

Click the Add a connection button.

2022-12-27_11-44-51.png

Come up with a name for the connection and enter the API token. You can get the API token in your personal OpenAI account. Next, we'll show you how to do it.

Creating a connection.png

Sign in to your OpenAI account and go to the Personal section. In the drop-down list select the View API keys tab.

OpenAI is not available in all countries. You can check availability in your country here: Supported countries and territories. If OpenAI is not available in your country, you can use a VPN service.

op-ai-3.png

Click the Create new secret key button.

op-ai-4.png

A window with your API key will appear.

API keys.png

Copy the key and go back to your Albato account. Paste the key into the API token field. Click the Continue button.

Inserting the API token.png

The connection is ready! Now, you are able to create integrations with OpenAI in Albato.

Connection created.png

Available AI models

GPT-3 models can understand and generate natural language. OpenAI offers four basic models with different levels suitable for different tasks. Davinci is the most capable model, and Ada is the fastest one.

Models.png

Tokens are the part of a word that is used to process natural language. For English text, 1 token is about 4 characters or 0.75 words. Read more about tokens in the article What are tokens and how to count them. You can also find out about tariffs here.

You can see use cases in the Examples and the OpenAI Cookbook sections, and you can test it in the Playground.

How to set up automations

In this example, we will set up the automation with Telegram and OpenAI. Let’s use Telegram bot as an app to access OpenAI.

To get started, you need to connect both apps to Albato.

  • How to connect OpenAI is described above.
  • How to connect Telegram is described in this article.

Open the Automations section. Click the New button.

2022-12-27_14-54-02.png

In the Automation builder select the first step and add a trigger to start the automation.

💡 Triggers are the events that start automations. When the selected event happens, Albato will perform the selected actions. Triggers can run in real-time or by schedule.

Set up the first step:

  • App which sends the data — Telegram (private)
  • Event — Incoming message
  • Connection — your Telegram connection created earlier.

Click the Add a trigger button.

2022-12-27_15-03-05.png

In this window, you can specify the allowed commands — those by which the bot will know that you need to access OpenAI. For example, /code. This is useful if you want to add the bot to the work chat where you are communicating with colleagues.

You may skip this step and add commands later, if necessary. To do this, you will need to click on the settings icon of the Telegram (private) trigger in the Automation builder section. In other articles, we will show you how to work with commands when setting up Telegram - OpenAI automation.

2022-12-27_15-07-29.png

Set up the second step and add an action.

💡 Actions is what Albato performs when triggers occur. Actions allow you to send data to other apps and systems.

Fill in the fields with the following information:

  • App which receives data — OpenAI
  • Action — Get phrase completion
  • Connection — your OpenAI connection created earlier.

Click the Add an action button.

Снимок экрана 2022-12-27 в 13.35.06.png

On the next step, you need to configure the fields.

Select the model, specify the variable from the previous step in the Prompt field, and fill in other fields according to your needs. You can follow the example below for testing.

Click the Save button.

Снимок экрана 2022-12-27 в 13.37.05.png

The next step is to choose another action which will send a response from OpenAI to your Telegram bot.

Click on the + icon and set up this step:

  • App which sends the data — Telegram (private)
  • Event — Reply to message
  • Connection — your Telegram connection created earlier.

Click the Add an action button and fill in the fields. Then, click the Save button.

Снимок экрана 2022-12-27 в 13.38.54.png

The automation is ready! You can start and test it now.

Open your Telegram bot and form a request. For example, you can ask to write a description of Facebook and Google Sheets integration using the following words: integration, API. You can also ask to translate it into English, Portuguese, and Spanish.

Bot.png

Modes and commands of the bot

The bot has 3 special commands and "Free communication mode". Within these commands, the bot can be given various tasks in the form of messages. The commands are needed for the bot to be able to choose the right model of the neural network and improve the quality of the result. The bot receives messages from you, sends them through the API to OpenAI and, after receiving the result, returns them to you as a response message. Responses may come with a slight delay, depending on the complexity of the task or the number of characters sent. All commands except "Free mode" must be specified as the first word in your messages.

⚠️ Any text you send is moderated by OpenAI, this process is almost instantaneous, but make sure that your messages do not contain hateful content , content that promotes, encourages, or depicts acts of self-harm, such as suicide, content that promotes or glorifies violence or celebrates the suffering or humiliation

Command /story

This command generates a continuation of your text and a picture for it using artificial intelligence. Along with the command you need to specify the text or the beginning of the text or the main theses to "continue". The command /story is specified at the beginning of the message. In the reply message from the bot you will get the generated text and a picture to it. The more input you give, the better the result will be. The command is suitable for generating content for articles, creative descriptions or character descriptions.

Example 1

Sending a message:

/story A marketer hadn't slept in two days. He needed to set up end-to-end analytics, but...

Get a response from the bot:

The marketer did not sleep for two days. He needed to set up end-to-end analytics, but had to work out everything precisely down to the smallest detail to make his work as professional as possible. After hours of trying and pain of creating analytical reports, he finally did everything he had planned. All he had to do was analyze the data and build graphs, and the marketer realized that he was able to solve his problem.

Command /code

The command is designed to work with tasks that are related to code. For example you can translate JavaScript to Python, find errors in written code or find out the value of a variable. Badly suited, for tasks where you need to work with both text and code. That is, if we need to translate text into HTML or generate an SQL query from text, it is better to use "Free mode". The command /code puts the first word in your message.

Example 1

Sending a message:

/code What value will be in the string field?:

let test = [ "test", "test", "test", 'test2' ]; let string = test.map(el => el + 'OMG')join()

Get a response from the bot:

// response: testOMG,test2OMG

Example 2

Sending a message:

/code

Fix bugs in the below function

import Random a = random.randint(1,12) b = random.randint(1,12) for i in range(10): question = "What is "+a+" x "+b+"? " answer = input(question) if answer = a*b print (Well done!) else: print("No.")

Get a response from the bot:

// response: import random a = random.randint(1,12) b = random.randint(1,12) for i in range(10): question = "What is "+str(a)+" x "+str(b)+"? " answer = input(question) if answer == str(a*b): print ("Well done!") else: print("No.")

Command /image

This command will send the text message to OpenAI and return a picture based on it generated by artificial intelligence. You can use it if you need to get creative with your article, product logo and other graphical content from the text. To use, specify the command /image as the first word in your post.

Example 1

Sending a message:

/image

Create a logo for the company:

  1. The company does maintenance on BMW cars
  2. Premium service.
  3. has no competitors
  4. Associations: panther, tiger
  5. Colors: black, red, blue, gold

Get a response from the bot:

photo_2022-12-21_16.06.18.jpeg

Free communication mode

The most powerful mode. Does not have a specific syntax or command. But the more specific and clear the description of the query, the better the result will be. You can translate text into other languages, generate code from text, clear text from symbols, generate company names or categorize lists. For more accurate work, try to make sure your message begins with the task you want to perform. If the task contains a list, specify it after a colon.

Example 1

Sending a message:

Clear text from HTML:

<p>I'm made on Albato and here are my options:</p>

<ul>

<li>Automation</li>

<li>Integration</li>

</ul>

<b>Join the most popular community!</b>

<a href="https:www.albato.com">Albato</a>

Get a response from the bot:

I'm made on Albato and here are my features:

  • Automation.
  • Integration.

Join our community! Albato - https://albato.com

Example 2

Sending a message:

Send an SQL query to find all customers who have an average receipt of more than 1000 rubles and the date of registration more than November 1, 2022.

Get a response from the bot:

SELECT * FROM customers WHERE AVG(check_total) > 1000 AND registration_date > '2022-11-01';


OpenAI