The title of the post has "alexa sorting hat" - that's why I asked about (Amazon) Alexa?
Wiring up the motor: depends what type of motor it is (DC, stepper, servo etc.) and can you power it from the pi or need a separate power source.
That link I gave earlier has examples of how to wire up motors etc.
And this link uses a motor controller board to drive two 5V motors
https://projects.raspberrypi.org/en/pro ... mputing/15