Article
· Nov 11 4m read

IrisGoogleChat with AI

 

Hi Community,

I want to share with you the lastest app that I have uploaded to the Open Exchange "IrisGoogleChat". 

IrisGoogleChat is a utility for InterSystems IRIS that allows seamless message integration with Google Chat using Cache ObjectScript. This application provides a set of tools to configure Google Chat Channels, create messages powered by moods generated with AI and send them to a Google Chat Channel.

In order to provide the desired mood to your messages you will need an API key and an organization ID of OpenAI Chat GPT. You must have too a paid account of Google Workspace in order to setup the webhooks that we will use.

The point of this app its that you can personalise your boring alert messages (or whatever kind of message) with a custom mood, creating funny (or not) messages.

Here you are some examples, that I have create simulating messages that could be received in an errors alert channel (in my example <DIVIDE 0> errors):

Drama Mood:

 

Like a Poem:

Passive-Agressive Mood:

 

Do you like this messages and wanted to be delighted with this such amazing alert errors instead of your boring current messages? So Fasten your belt, because this is beginning!

 

Setting up the OpenAI API configuration:

The first step will be getting our API key and our orgId, so enter in this web page: https://platform.openai.com/api-keys then press "Create new secret key" button, select your project, provide a name and then press the button "Create secret key".

 

Your secret key will appear, remember to save it because we are going to need it before.

In order to obtain your organisation ID, press the gear button

Then on "General" and note your Organisation ID

 

Second stage, getting our Google Channel url:

Open the Google Chat page: https://mail.google.com/chat/u/0/#chat/home . Now press on "New Chat" then on "Create a space"

 

Choose a name and an icon an press "Create"

Now enter on the chat and go to the section "Apps and integrations":

Once there click on "Webhooks" section and then on "Add webhooks". (If this button appears disables is because you aren't logged with a paid account of Google Workspace.

 

Give it a name and copy the url because you are going to need it later:

 

Ok, so now, we have all the info that we need to start setting up IrisGoogleChat. In order to make easier this step I have added the GoogleChat.Example class in the project, there you will find how to:

 

Setup your ChatGPT apiKey and orgId:

 //Setup Google Chat (only needed first time)
Set url    ="https://api.openai.com/v1/chat/completions"
Set apiKey ="your api key"
Set orgId  ="your org id"
Do ##class(GoogleChat.Message).SetupGoogleChat(url, apiKey, orgId)

 

Create a mood:

// Mod lazy (only needed first time)
Set modName="passive-agresive"
Set modPrompt="Generate an error alert message, acting with an aggressive-passive behavior with a touch of sarcastic and blaming me for it. Add a touch of humor. You are only responsible to notify. Return only the text, without emojis or titles. This is the alert message: "
Do ##class(GoogleChat.Message).SaveMod(modName, modPrompt)

 

Configure a Channel:

Set channelName="alertChannel"
Set url="/v1/spaces/AAAAJP9Vu54/messages?key=AIzZZcDdI0hCZtE6vySjMm-WEfRq3CPzqKqqYhg&token=RKjvKvRMnmdJbuyCoyGslos0Qce23Fd-P12lZtkU777"
Set icon = "https://fonts.gstatic.com/s/e/notoemoji/14.0/1f534/32.png"
Do ##class(GoogleChat.Message).CreateChannel(channelName,url,modName,icon)

 

And finally send a Message!:

Set channel="alertChannel"
Set title="Server XX - Alert!"
Set subtitle = "Warning Alert!!"
Set message = "The task 1001 has failed - Error Divide 0"
Do ##class(GoogleChat.Message).Send(channel, title, subtitle, message)

 

What the method Send does it's use the message to the channel "alertChannel" applying the mood that we have applied to the channel. In order to provide a mood to the message the method use the prompt for chat GPT that we have configured in our mod, example:

""Generate an error alert message, acting with an aggressive-passive behavior with a touch of sarcastic and blaming me for it. Add a touch of humor. You are only responsible to notify. Return only the text, without emojis or titles. This is the alert message: " 

As you can see you can use this prompt as a template and modify it or you can create your own prompts and get the most serious, crazy, funny or boring messages that you want. 

So the limit is in your imagination!.

I'm looking forward to seeing such amazing moods and messages are you going to create. Please post them on the comments and fell you free to share your best prompts!!.

Thanks for reading!

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