stanford-oval / thingpedia-common-devices

Thingpedia interface code for commonly used devices
Other
38 stars 28 forks source link

Add a better joke API #73

Open gcampax opened 5 years ago

gcampax commented 5 years ago

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

stephanedreyfus commented 4 years ago

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

gcampax commented 4 years ago

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.

stephanedreyfus commented 4 years ago

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.

gcampax commented 4 years ago

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.