How to create a single button which triggers a series of actions

Hi, I am new to home assistant, so I managed to get everything installed on my raspberry pi 3 and also managed to create switches, which controls some of the GPIO pins. My question is how can I create a single software button, which can set 2 of the GPIO pins high, wait 2 seconds and set them low again?

This is the code for the gpio switches:
- platform: rpi_gpio
02: Relay_1
04: Relay_2
invert_logic: true

I have connected one relay to each GPIO pin and control a solenoid valve with the first one and an electric pump with the second one. But unfortunately I am very new to home assistant and I just could not manage to program the small automation required to turn on both relays, wait 2 seconds and close them again.

This is the boolean input, which I think is suitable for this application
name: Turn Water On/Off
initial: off
icon: mdi:water


Use a script as mentioned above, and then use the “delay” function in that script, no need for booleans

Thanks a lot! I done with a script and it is now running fine.
I just haven noticed that the script also has an on/off switch, so I don’t actually need a separate button to run the script.