How can action potentials be generated through thoughts?
This paper addresses the question that you are asking. The study is based on conscious decision making in rats.

Performance of rats were assessed in the following task:

The rats have to poke their snout into a waiting port until a auditory signal (beep) is heard.
After first beep the rats can get a small reward (small amount of water) in the reward port. However if the rat waits for a second beep it gets to have a bigger reward. 

So there were three behavioral outcomes in the experiment done with 37 individuals:


Short-poke trials: Those that didn't wait for the signal (8.3 ± 4.6%)
Impatient trials: Those that waited for the first beep but did not wait for the second beep (58.8 ± 3.9%)
Patient trials: Those who successfully got the bigger reward. (32.9 ± 1.4%)


The impatient ones did not usually quit immediately after the first beep. This was not a lethargic response to signal but a moment of conflict between two decisions. There was a distribution of waiting times. The patient ones immediately responded to the second beep and took their reward.

Neural activity was studied in the M2 (secondary motor) cortex of impatient rats during the tasks and two kinds of neural activity was observed:


Ramp-to-threshold: Firing rate kept increasing till the end of waiting time suggestive of a neural threshold to quit waiting. (Fig 1)
Steady-transient activity: Firing rate correlated with waiting time i.e. higher firing rate higher the waiting time. This could constitute the neurons that are making the rat wait. (Fig 2)


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


  Figure 1: Ramp-to-Threshold.  Reproduced from Murakami et al. (2014) Nature Neuroscience 17,1574–1582


&nbsp;&nbsp;&nbsp;&nbsp;


  Figure 2: Transient activity.  Reproduced from Murakami et al. (2014) Nature Neuroscience 17,1574–1582


It was also observed that this activity is task specific. The neurons that showed a certain activity in the above tasks did not behave the same way in the same rats performing a slightly different task.

So action potential is generated in the brain by "thoughts". However these thoughts are not generated de-novo. Any conscious decision is based on memory of past events and similar events evoke those memories, which in cellular terms is generation of action potential. In this case the action potential is generated in response to the rats' sensory input in the form of a beep. Other kinds of responses are instinctive and the brain circuitry has evolved to generate these kinds of responses to certain stimuli such as fear. The above example is a study of conscious decision making based on an acquired memory.