Let H5P content types use external services such as GPT, image generators, messaging services, etc.
tl;dr
Add a way to let H5P content types use external services such as GPT, image generators, messaging services, etc.
Background and basic idea
There are plenty of things that one can do with the programming language JavaScript. That means one could do them with H5P as well. However, there's not always a library that one can reuse to import functionality. Writing the same functionality from scratch would not only mean to have resources to do so available, but expertise in some field may be required, too. Sometimes, doing things inside the browser with JavaScript does not make sense for performance reasons. Think of video encoding for instance. While it could be done in theory (probably with some limitations), it made more sense to leave computation to a server. And there sometimes are sites on the web that already offer to do exactly the one thing that one needs on some server and that site potentially also offers an interface that one can talk to from within JavaScript. Perfect! Can't we use that for an H5P content type? Hook it up to GPT for instance and do something cool? Or to some video encoding service maybe? Or some audience response service? Or ...
Yes. And no. Letting JavaScript talk to other servers than the one the JavaScript comes from can cause issues. That let aside, often services require you to register and to log in, potentially even because you need to pay for using them. You'd need to enter your credentials in the H5P content types' settings, and thus anyone that uses the content type could grab your login information. That's not something that anyone could want.
So, there's nothing that one could do? There is, of course. One could create an extra plugin for a platform that runs H5P. That extra plugin runs on the server. The H5P content type could talk to that plugin, the plugin could communicate to a 3rd party service (that could be hosted on the platform's server or somewhere on the web). That plugin could also take care of credentials safely. That would work, but for the H5P content type to run, it would require that the extra plugin is installed - and available for the platform in the first place. This approach can easily bust the idea of H5P content being able to run everwhere.
Luckily, there is another way. However, it would require to amend the feature set of H5P core and to change the H5P integrations such as the H5P plugin for WordPress or moodle. An H5P content type would find a standardized interface in H5P core where it can send requests intended for another server to. H5P core would check whether the H5P integration offers to relay the request to the target server and use that offer if available. The H5P integration would check whether the author of the content is allowed to use the remote service, provide either server-wide credentials that an admin provided or some user-specific credentials and then send the actual request to the other server. The response (or some error message) would eventually find its way back to the H5P content type.
Basic ideas
H5P content type
- "As an H5P content type, I want to be able to retrieve a list of available services that it can talk to in order to determine whether I can use the service and to let the user know if not."
- "As an H5P content type, I want to be able to send a request to some remote server in order to receive the response and react to it."
H5P core
- "As H5P core, I want to be able to retrieve a list of available services that I can offer to H5P content types in order to satisfy their request."
- "As H5P core, I want to be able to relay a request from an H5P content type to an H5P integration and to return the response or some error message.'
H5P integration
Could be a solution fully integrated into the platform or use some reusable client like for the H5P OER Hub in order to reduce porting effort.
- "As an H5P integration, I want to be able to answer H5P core's query about available services."
- Will check for available services.
- Will check for permission of author/user to use the service.
- "As an H5P integration, I want to be able to relay a request from H5P core to a remote server and to return the server's response or some error message.'
- Will check for availability of service
- Will check for permission of author/user to use the service
- Will check request against template set
- Will add credentials to request if necessary (global credentials set by admin if available, author credentials or user credentials otherwise).
- May need to be able to handle JWTs or similar to support all services.
- "As an admin, I want to be able to configure services that H5P content types can use."
- endpoint (template to be able to replace credentials placeholder in request)
- global credentials (if applicable)
- "As an admin, I want to be able to configure the permissions of platform users to use a service by using the platform's system for rights management."
- "As an author/user, I want to be able to set and edit the credentials required to use the service."
Your turn!
It is very likely that this does not cover all needs, and it is also possible that there's a technical or organizational reason why this will not work (server-side stuff is not my strength) or not be done. That's why I invite the H5P community including H5P Group to share their thoughts here. That means you! Come on, you must be interested if you have read this far!
totoro
Sat, 12/02/2023 - 14:03
Permalink
I love your idea.
I upvote this idea. With the advent of generative AI, I think this integration is inevitable. Otherwise, current H5P services might look old-fashioned.
otacke
Mon, 12/04/2023 - 11:24
Permalink
Thanks!This is not just about
Thanks!
This is not just about generative machine learning. There are all kinds of services that one could use, ranging from receiving weather forecasts or facts from Wikipedia projects to calendar management or random facts about cats ... Have a look at https://github.com/public-apis/public-apis for instance. Not saying that all these make sense for a content type, but machine learning services is really just one aspect. Having this "Service API" would open up the door to a lot more.
Best,
Oliver