thingpedia-common-devices icon indicating copy to clipboard operation
thingpedia-common-devices copied to clipboard

Add a better joke API

Open gcampax opened this issue 5 years ago • 4 comments

I love dad jokes, but they after a while even I admit they get a little cheesy. Maybe we should expand our joke selection.

gcampax avatar Apr 25 '19 16:04 gcampax

Would love to help with this. This would be my first serious coding contribution attempt.

stephanedreyfus avatar Oct 05 '20 01:10 stephanedreyfus

Hi Stéphane, thanks for the offer to help! This issue requires finding a new joke API. Do you have one in mind already? If not, the first step will be to look into API repositories such as ProgrammableWeb, and evaluate the different APIs for joke quality, appropriateness, and variety.

gcampax avatar Oct 06 '20 18:10 gcampax

In a cursory search I found this: https://sv443.net/jokeapi/v2/ What's nice is it allows for a certain amount of content control. They do offer a way to contribute jokes, but not as part of their API.

stephanedreyfus avatar Oct 07 '20 16:10 stephanedreyfus

Sounds good! The next step then is to bind the API, replacing the existing joke API. To do so, I recommend skimming through the Thingpedia guide to understand how Thingpedia skills are defined.

It's possible that the API fits as a REST API (see the relevant chapter in the guide), in which case all you have to do is replace the URL and change the JSON keys. If it on the other hand the API does not fit as a simple REST API, you'll need to write a file called "index.js" mapping the response from the server into the format declared in the manifest (guide chapter). From a cursory look, it seems "twopart" jokes don't fit the REST API, because the text of the joke is split across two messages.

You might also want to add a new parameter to manifest to select a type of joke. Or maybe not. It seems the categories are not very rich.

gcampax avatar Oct 12 '20 17:10 gcampax