Assist, tell a joke!

Ok, finally you can say goodbye to Google Assistants “Tell a joke”. Assist can do it too :grinning_face_with_smiling_eyes:

So what do we need?

In configuration.yaml, this will tell the joke and update it afterwards for the next joke:

intent_script:
  TellJoke:
    speech:
      text: "OK: {{ states('sensor.joke') }}"
    action:
      service: homeassistant.update_entity
      target:
        entity_id: sensor.joke

Next we need to configure the custom sentences in “/config/custom_sentences/en/telljoke.yaml”:

language: "en"
intents:
  TellJoke:
    data:
      - sentences:
          - "Tell a joke"

Last but not least you need to create a sensor that grabs the joke.
Different options, for english jokes you can use jokeapi.dev:

- platform: rest
  resource: https://v2.jokeapi.dev/joke/Any?format=json&safe-mode&lang=en
  name: joke
  value_template: "{{ value_json.joke }} {{ value_json.setup }} {{ value_json.delivery }}"
  scan_interval: "01:00"

Or maybe better suited for german jokes is “witzapi.de”:

- platform: rest
  resource: https://witzapi.de/api/joke/?limit=1&language=de
  name: joke
  value_template: "{{ value_json[0].text }}"
  scan_interval: "01:00"

Now just reload your config and ask Assist to tell you a joke as often as you like!

9 Likes

Cool, thanks for sharing!