From LotusScript to ChatGpt and vice versa

My developer colleague, Fabio di Paola, has done some experimenting with ChatGPT and he successfully used it with LotusScript.

He published an article, in Italian, on our blog, here.

To save you the hassle of translating, here it is in English:’s ChatGpt is kind of the main topic of the last few months, we’ve all tried to use it and we’re thinking about how to use it in real cases. Precisely in the light of these considerations, the first question we asked ourselves was “but will I be able to use it within a Domino application?”

The answer is Yes , it can be done : we are investigating it these days and the first results are positive ; It’s true that sometimes, from theory to practice, surprises are always discovered and therefore the last word is never said, but here I feel optimistic. LotusScript can query ChatGpt and receive its response.

OpenAi has released APIs to connect to ChatGpt but, at least for now, they are limited to Python and node.js . In addition several communities have already published code libraries to connect to ChatGpt from other languages. It’s hard to think that something like this will ever be done for LotusScript .

But going to see how the calls are made and trying to experiment on the ChatGpt playground you can understand the mechanisms that underlie the calls to ChatGpt.

The first thing needed, regardless of the code used, is the API key for authentication: this is obtained by registering on the site and then going to the details of your account under ApiKeys It is a string of 51 characters which must then be passed
to every call.

At this point I started building a first prototype in LotusScript, the main parts are two:

  • The NotesHTTPRequest class to send the request and get the response
  • The construction of the Json to be sent and then the parsing of the return Json

For the NotesHttpRequest there is little to say, just remember that the API key must be managed as a header of the request.

For the Json part there are obviously various possibilities to build it and then to parse it, obviously the important thing is to follow the ChatGpt rules: here too, using the playground you can easily understand how to build it, which parameters to pass and how.

A typical example is this:

"model": "text-davinci-003",
"prompt": "Ask here the question.",
"temperature": 0,
"max_tokens": 100,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0,
"stop": ["\n"]

Also to parse the response there are several possibilities, you can use the NotesJSONNavigator class in LotusScript or a library already present on the net like this one /JSON+LotusScript+Classes in OpenNTF.

At the end of all what I got is a form in which to enter the question with a button that sends it, parses the answer and writes the answer itself in a field below, all using only LotusScript :

I add a curiosity: among the questions I asked ChatGpt I asked if he knows LotusScript (with an affirmative answer) and then I asked if he could write me the LotusScript code to send requests to ChatGpt. Again the answer was yes but the code he gave me had several errors.

I replied pointing out the various errors and corrections were proposed to me which were equally incorrect. As far as I understand at the moment ChatGpt doesn’t “learn” from its mistakes, so it’s possible that asking it the same questions again will result in the same errors.

Problem with Prometheus in Sametime monitoring dashboard
The Domino 12 Update Certification is now available for 8.5 Certified Administrators


  1. You speak of GPT, not ChatGPT, don’t you?

    • No, I am referring to ChatGPT. My colleague used the OpenAI API, I don’t know if those are used also by GPT.

  2. here can you find a template (ChatGPT APIs for HCL / DOMINO),63742.msg405688.html#msg405688

Leave a Reply

Your email address will not be published / Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.