In a pot, I usually put a drizzle of dishwashing liquid. And then water it in part by part. e.g. If you typically water 1 gallon, do 1/4 gallon at a time, wait 30 secs to a minute in between. Or it would overflow with suds and you can have a tray below to catch all that and reapply. Or you can use the formula for spray below for a whole pot soak(I left that in for about an hour). That usually kills most of the ants in the first try.
Then, I pull the rootball out and check the surviving ones. By now, they are in chaos and no time to sting you. And use diluted dishwashing liquid (7 teaspoon to a litre) to spray on to the rest. Put it back in the pot. Come back in 15 mins and pull the rootball to check again.
The toughest one I had to do that spray 2 times. Most were killed in the first wash. The reason to use dishwashing liquid is to clean off their scent. Otherwise, they would keep coming back to rebuild the nest.
For smaller pots, I just use spray but it doesn't penetrate deep enough for large pots.
I have also immersed the whole pot(larger one) into bucket/tubs but then you need more dish washing liquid.
I have tried other non-lethal methods to persuade them to leave but they won't once they start building.
Ants here like to build nests among leaf debris so I make a habit to clean them off the floor or the pots. I have been stung badly multiple times by simply stepping on the wrong leaves.