How do I use a slider in my automation?

I have an automation that turns a ceiling fan on.

action:

  • service: fan.turn_on
    target:
    entity_id:
    - fan.ceiling_fan_with_light
    data:
    percentage: 50

Percentage controls the speed of the fan and I want to replace the fixed number by the value of a slider,

input_number.ceiling_fan_speed

What is the correct syntax?

Please format your config with this button </> not the quote button.

The format is:

data:
  percentage: "{{ states('input_number.ceiling_fan_speed') }}"