Add generic tap_action, etc to custom card

Hi all,

Like the title. Does anyone know how to add the generic Home Assistant tap_action, hold_action etc. to my custom card? I want to use it from the yaml/ui setup, so now by default a standard action.

- type: custom:mycard
  entity_id: bla.bla
  tap_action:
    action: perform_action

I found this in the docs, but cannot seem to get it working:

// Define the action config
const actionConfig = {
  entity: "sensor.temperature",
  tap_action: {
    action: "more-info",
  },
  hold_action: {
    action: "assist",
    start_listening: true,
  },
};

// Open more info on tap action
const event = new Event("hass-action", {
  bubbles: true,
  composed: true,
});
event.detail = {
  config: actionConfig,
  action: "tap",
};
this.dispatchEvent(event);

// Open assist dialog on hold action
const event = new Event("hass-action", {
  bubbles: true,
  composed: true,
});
event.detail = {
  config: actionConfig,
  action: "hold",
};
this.dispatchEvent(event);