How to ask a professor to supervise my undergraduate thesis research?
Just talk to them as if they were a human being. Give them the info you just gave us, ask if they are interested, keep the email short and to the point. Here is an example email, adapt as needed.

Dear Prof. XXX,

(or whatever is the appropriate salutation where you live)

I am a second year student in [field] at [university]. I am interested in [domain].
Soon I will start my undergraduate thesis research. Professor YYY, who teaches us [course], recommended that I contact you, and I would be interested in having you supervise my thesis. Would you be interested in supervising my undergraduate thesis research?
I am at your disposal if you need more information and/or would like to meet me. Thank you for your time.
Best regards,
ZZZ

(or whatever closing formula is appropriate where you live.)
I don't know if this is perfect (English isn't my native language), but you get the idea.