What's new?
Who uses Directual?
What can be built on Directual
Learn Directual
Why Directual?

Connecting ChatGPT and Directual scenarios

March 12, 2023

In this lesson, we’ll learn how to use the Open AI ChatGPT plugin with Directual no-code scenarios to create a Telegram bot.

The video tutorial

Step 1. Connecting Telegram-bot to your app.

Go to BotFather to create new Telegram bot. You can then either create a new app using Telegram bot template or install the Telegram plugin in your existing app.

Directual Telegram-plugin

Step 2. Installing ChatGPT-plugin

First, go to OpenAI and create an account (EU/US telephone number is needed). Then, get the API key. Once you have the key, you can install the OpenAI plugin.

Directual OpenAI-plugin

Step 3. Launching a scenario for message processing

You can explore the techniques for building Telegram bots on Directual in our documentation. Here we’ll just play around one scenario that is set to trigger on every new object in TMessageIn data structure.

Steps configuration:

Steps configuration:

  1. Start step. One context variable: response (type of string or file, doesn’t matter)
  2. Telegram step. Just an action of typing. OpenAI API usually processes the request for a few seconds. The bot will be “typing…” that time.
  3. Condition step. Checking if user wants to have a picture generated. We use regular expression here.
  4. Text-to-image ChatGPT call. We send text from telegram message to OpenAI and save response to a context variable.
  5. Telegram step. Send a generated picture to the user.
  6. Text-completion ChatGPT call. We send a prompt to ChatGPT (including the chat history, that we store on TChat object, in a certain string field).
  7. Telegram step. Send a generated text to the user.
  8. Edit object step. Add user’s request and bot’s response to chat history.

Step 4. Adding history reset

We’ve added field for storing chat history on TChat object

Storing chat history on TChat object

Let’s add a condition to the scenario if message text equals “/start”, clear the chat history and start from the beginning.

Reseting the context


That is it! The dialogue with the bot may look like (it gets the context):

Example of a dialogue with the bot.

If you have any questions, shoot us a message on hello@directual.com. Also, don’t hesitate to join Directual community of no-coders.


What is OpenAI?
What is OpenAI?

OpenAI is a research laboratory based in San Francisco, California, focused on artificial intelligence (AI) research and development. Founded in December 2015, OpenAI's mission is to ensure that artificial general intelligence (AGI) benefits all of humanity.

What is ChatGPT?
What is ChatGPT?

ChatGPT is an open-source natural language processing (NLP) model developed by OpenAI. It is a transformer-based language model that uses deep learning to produce human-like conversations. ChatGPT is designed to generate human-like responses to

How to use no-code and ChatGPT?
How to use no-code and ChatGPT?

To use no-code and ChatGPT, you will need to create a chatbot using a no-code platform such as Directual. Once you have created your app, you can integrate ChatGPT into it by using the OpenAI-plugin. This will allow you to generate human-like interaction to your app.

Meet & greet like-minded no-coders

Hop into our cozy community and get help with your projects, meet potential co-founders, chat with platform developers, and so much more.