Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Using the ChatGPT API in Scripts

June 02 (10 months ago)

Has anyone successfully created a Roll20 script that uses the ChatGPT API to get a response to a prompt, like “return a random first name from dark age Britain”? This would replace the need for a bunch of rollable tables for stuff I want and give nearly endless possible random unique returns.

June 02 (10 months ago)

Edited June 02 (10 months ago)
GiGs
Pro
Sheet Author
API Scripter

Abandon any hope of using chatGPT or any LLM-based AI with roll20.

If something can be created as pure javascript or htnl, it can be made with AI, but if it needs *any* roll20 specific features, it can't - and APIscripts always do.

LLMs need vast, vast userbases of existing code to draw from across the web. Javascript and HTML code samples exist in such numbers, but roll20 doesn't.

Now if you know the fundamentals of how to build Roll20 scripts, you could use chatGPT to make the job easier: get a javascript function out of it that does something like you describe, then tweak it to work in the roll20 API.

I don't see why you'd need to use chatGPT to do what you describe though - you just need a list of names, and build a rollable table - something like the Table Import script would do the trick.

June 02 (10 months ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

I have used ChatGPT for things like creating very specific and technical functions, which I then adapted for use in Roll20 scripts, but there is just too much that is specific to Roll20 for it to have general use. It does not know the structure of Objects in the Mod System, the syntax of Roll20 functions, what constitutes an Event, and much more.

Also, Even if you were to build the script you envision, it could not link directly to the Roll20 chat box (without a highly-specialized browser plugin, requiring knowledge of both Roll20 (which runs in its own sandbox) and ChatGPT's API. They cannot "talk to each other". And if it were, it might not even be legal due to licensing.

June 02 (10 months ago)

If Roll20 scripts are JavaScripts, can’t we use the following blueprint to use the ChatGPT API from within our scripts, or is the Roll20 sandbox a closed system with no way for us to use NodeJS or import the ChatGPT API?


https://runjs.app/blog/chatgpt-javascript-api


I’m a novice JavaScript developer so apologies for some ignorance.

I think the benefits of using ChatGPT over rollable tables is that I don’t have to set up rollable tables with a finite number of entries that might get duplicated over many gaming sessions and there’s a lot of labor in importing a bunch of Excel spreadsheets into all the tables I might want to create. A single well phrased request could return a descriptive paragraph about a shop or building my players randomly chose to visit, for example.



June 02 (10 months ago)

I’m not trying to use ChatGPT to create Roll20 code. I’m just trying to use ChatGPT to help me fill in my RPG “world” with descriptive details that don’t have specific impact on the story but need to be provided for “color”, to help make the world more “real”. My own imagination and ability to come up with an immersive description when the players do something unexpected has its natural limits.

June 02 (10 months ago)

I’ve been using ChatGPT to generate tables of 100 things and I’ve been importing those tables into rollable tables, but that’s a lot of labor that would be simplified if I could just call ChatGPT from within a Roll20 script.

June 02 (10 months ago)

Roll20 is a closed sandbox that doesn’t interact outside of Roll20. 

June 03 (10 months ago)
GiGs
Pro
Sheet Author
API Scripter


Andy B. said:

that’s a lot of labor that would be simplified if I could just call ChatGPT from within a Roll20 script.

That can't be done. As Jarren says, roll20 doesn't interact with anything outside of roll20.


June 03 (10 months ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

I think I said it as well. :D

June 03 (10 months ago)
GiGs
Pro
Sheet Author
API Scripter

You did, I was just amused that Jarren used his own words basically, but very accurately.