Article
· Jun 8, 2023 2m read

Making your own Chat with Open AI ChatGPT in Telegram Using InterSystems Interoperability

Hi Community!

Just want to share with you an exercise I made to create "my own" chat with GPT in Telegram.

It became possible because of two components on Open Exchange: Telegram Adapter by @Nikolay Solovyev and IRIS Open-AI by  @Kurro Lopez 

So with this example you can setup your own chat with ChatGPT in Telegram. 

Let's see how to make it work!

Prerequisites

Create a bot using @BotFather account and get the Bot Token. Then add bot into a telegram chat or channel and give it admin rights. Learn more at https://core.telegram.org/bots/api

Open (create if you don't have it) an account on https://platform.openai.com/ and get your Open AI API Key and Organization id.

Make sure you have IPM installed in your InterSystems IRIS. if not here is one liner to install:

USER>    s r=##class(%Net.HttpRequest).%New(),r.Server="pm.community.intersystems.com",r.SSLConfiguration="ISC.FeatureTracker.SSL.Config" d r.Get("/packages/zpm/latest/installer"),$system.OBJ.LoadStream(r.HttpResponse.Data,"c")

Or you can use community docker image with IPM onboard like this:

$ docker run --rm --name iris-demo -d -p 9092:52797 -e IRIS_USERNAME=demo -e IRIS_PASSWORD=demo intersystemsdc/iris-community:latest

$ docker exec -it iris-demo iris session iris -U USER

USER>

Installation

Install the IPM package in a namespace with Interoperability enabled.

USER>zpm "install telegram-gpt"

Usage

Open the production.

Put your bot's Telegram Token into Telegram business service and Telegram Business operation both:

Also initialize St.OpenAi.BO.Api.Connect operation with your Chat GPT API key and Organization id:

Start the production.

Ask any question in the telegram chat. You'll get an answer via Chat GPT. Enjoy!

And in visual trace:

Details

This example uses 3.5 version of Chat GPT Open AI. It could be altered in the data-transformation rule for the Model parameter.

Discussion (8)1
Log in or sign up to continue