Upvote:1
You need a visa, because you will have to cross Thai immigration to enter at Chiang Mai and take the domestic flight to Bangkok.
You can get a visa on arrival for a stay of up to 15 days, but to ensure that you don't have any problems at the airline and to go faster through immigration, I recommend you get an e-visa in advance from the official Thai e-visa web site.