Thailand was almost colonized by the French during the Ayuthaya period, and after WW2 by the British.
In the first case, Constantine Phaulkon (during the Ayuthaya period) who occupied a senior position within the Royal Court and had significant influence, tried to open up Thailand for invasion by the French. However, his true intentions became known and Thailand closed its borders for a century in response.
The second case was following World War 2. The UK's intent was to retake Malaysia, Burma and add Thailand to its list of colonies following Japan's surrender. Fortunately for Thailand, at the end of the war, Thailand handed itself to the US rather than the UK (note this was a very calculated move by the Thais, especially the Seri Thai). The US had no intention of colonizing and therefore Thailand was off the hook.