Actions2
Get Random Joke
AI-generatedOverview
This node integrates with JokeAPI (v2) to fetch jokes in multiple languages with advanced filtering options. It supports three main operations:
- Get Random Joke: Retrieve one or more random jokes filtered by categories, flags to exclude, joke type, language, and optional search text.
- Get Joke by ID: Fetch a specific joke or a range of jokes by their numeric IDs.
- Get API Info: Obtain metadata about the JokeAPI such as available categories, flags, and supported languages.
This node is useful for automating humor content delivery, enriching chatbots, or adding light-hearted elements to workflows. For example, you can use it to fetch programming jokes in English excluding NSFW content or retrieve a specific joke by its ID for display.
Properties
| Name | Meaning |
|---|---|
| Categories | Select one or more joke categories. "Any" includes all categories and overrides other selections. Available categories: Any, Programming, Miscellaneous, Dark, Pun, Spooky, Christmas. |
| Exclude Flags | Exclude jokes containing these flags. Options include NSFW (Not Safe For Work), Religious, Political, Racist, Sexist, Explicit. |
| Joke Type | Choose the joke format: Both types, Single-part joke, or Two-part joke (setup & delivery). |
| Language | Select the joke language. Supported languages: English (en), German (de), Spanish (es), French (fr), Portuguese (pt), Czech (cs). |
| Search String (contains) | Search for jokes containing this text. Only works if exactly one specific category is selected (not "Any" or multiple categories). Example: "robot". |
| Amount | Number of jokes to retrieve (1-10). |
| Joke ID(s) | (For Get Joke by ID operation) Numeric joke ID or range of IDs (e.g., "15" or "10-20"). Required for this operation. |
| Operation | The action to perform: Get Random Joke, Get Joke by ID, or Get API Info. |
Output
The node outputs an array of JSON objects representing jokes. Each joke object structure depends on the joke type:
- For single-part jokes, the joke text is typically in a
jokefield. - For two-part jokes, there are usually
setupanddeliveryfields. - Additional metadata may be included such as
id,category,flags, andlang.
If multiple jokes are requested (amount > 1), the output is an array of such joke objects.
No binary data is produced by this node.
Dependencies
- External HTTP requests to JokeAPI v2.
- Uses Axios library for HTTP calls.
- No required credentials or API keys; the API is public.
- Optional: Node logging and error handling via n8n workflow utilities.
Troubleshooting
- Validation Error on Search String: If you specify a search string but select "Any" or multiple categories, the node throws a validation error because searching requires exactly one specific category.
- Invalid Joke ID Format: When using "Get Joke by ID", only numbers and hyphens are allowed. Invalid characters cause an error.
- API Errors: If JokeAPI returns an error, the node surfaces the message and additional info if available.
- Network Issues: Network errors or unreachable URLs result in descriptive error messages.
- Amount Limits: Requesting more than 10 jokes at once is not allowed and will cause an error.
- To handle failures gracefully, enable "Continue On Fail" in the node settings.