There are a couple of case governments (rekcioj) the verb danki can take.
danki iun por io
Zamenhof used the preposition por with the idea of interchange.
… due mi dankas vin por la prunto… (Z)
danki iun pro io
The preposition pro denotes i.e. the motivation of an action.
Mi dankas vin pro via instruo. (Z)
danko al iu pri io
Note also that you can express gratitude with the noun danko. With the noun Zamenhof used at least sometimes the preposition pri.
…sed al ĉiuj kune mi esprimas koran dankon pri ilia laborado… (Z)
A side note, although the verb danki is clearly transitive, i.e. takes a direct object danki iun, some authors have began to use the expression al iu with the verb too, i.e. danki al iu. Personally I consider such use bad style.
contemporary use
To my ears the noun expression sounds very formal, and a quick search in Tekstaro indicates that this kind of use is very rare.
A quick search in Tekstaro indicates that both prepositions por and pro are common with the verb danki, so the question is whether all authors make the distinction of interchange resp. motivation or whether they are even aware of that distinction. A furthermore complicating factor is that at least to me it looks like during the early years words counted for interchange, in more recent times more tangible things are required for to be regarded as interchange.
"Thank you for speaking to me"
English basically makes the distinction "speak to someone" resp. "speak with someone", where the former denotes that speaker expresses a feeling or a thought to someone, the latter denotes a conversation between two parties. However the distinction is not that clear-cut and sometimes these case governments are used interchangeably. Having said that here "speaking to me" can cause a mental image of a person A addressing a person B, i.e. B just listens what A says.
Esperanto tries to avoid these kinds of ambiguities by a more literal interpretation of prepositions. In other words paroli al iu is more about directing one's speech and paroli kun iu about conversating. Therefore I would use the case government paroli kun iu in Esperanto.
To summarise
- Dankon pro tio, ke vi parolis kun mi.
- Mi dankas vin pro tio, ke vi parolis kun mi.