Buy it before the airport
The arrivals hall is a bad place to discover that the phone has no eSIM, or that the carrier lock is still on. Dial *#06# at home. If the screen shows an EID, the phone has eSIM hardware. Then confirm with your carrier that the phone is unlocked. The menu path is in the eSIM guide: Add eSIM under Cellular or Mobile Service on an iPhone, and the SIM manager on Android, which each maker names differently.
Buy from a provider that states the country on the plan, and read when the validity starts. Many travel plans start when the eSIM first attaches to a mobile network. Some start on the day you install, or on a date you pick. That sentence is on the plan page. If you skip it, the days can run out while you are still at home.
Install on wifi, then label the lines
Use the provider's app or the QR code. The phone will ask you to add a cellular plan and may ask you to name it. Name it after the country or the provider so you do not toggle the wrong line later. Installation downloads a profile. It can succeed with the new line switched off.
Leave mobile data on your home line for now, and leave the new line off if the plan starts on first connection. If the provider says installation itself starts the clock, install closer to departure, still on wifi, and do not wait until you are on the plane's cellular network.
On the day you land
After you are off the plane, turn the travel line on and set it as the mobile-data line. Turn data roaming on for that line only if the provider's instructions say the plan needs roaming enabled to attach. Turn data roaming off on the home line before you do this, not after. iPhone keeps a separate roaming switch per line. Android puts it under the SIM you have selected, and the wording is not the same on every phone.
Keep the home line on for calls and SMS if you still want bank codes and ordinary texts. A data-only eSIM will not receive those codes. Sending a text from the home line while abroad can still be a roaming charge. Receiving an SMS is, at many carriers, free, but that is a question for your carrier's current roaming page, not a promise from this one.
If it does not connect
Toggle airplane mode, then try the provider's suggested network or APN. Those steps are in their app, and they differ. Hotel wifi is a fine place to re-read them. Buying a tourist SIM at the airport counter is a reasonable backup when the eSIM will not attach and you need data the same day. In Thailand the counter will want your passport, which the Thailand guide covers.