The New Scientist had an article on the antiquity of the building blocks of nervous systems, written by Michael Marshall. (here) Rather than talking about similar chemicals in primitive animals, fungi, plants and even bacteria, he looks at a single celled Monosiga brevicolis which aggregates under some conditions and so is at the boundary between single-celled and multicelled organisms. It has many ingredients needed for a nervous system.
Some of the building blocks are: ion channels and voltage gated calcium ion channels (both found in bacteria), ion channels that can give a traveling action potential on a cell membrane, gap junctions, receptors for glutamate in other messengers, release of messengers during action potential. All these are found in organisms that are not multicellular.
Back to the collared flagellate or choanoflagellate, M brevicolis, and its equipment. It has no nervous system, being a single cell, but it does have a lot of the where-with-all. Marshall mentions a number of papers and I quote parts of their abstracts below.
Burkhardt etal, Primordial neurosecretory apparatus identified in the choanoflagellate Monosiga brevicollis. PNAS 2011:
We found that the Munc18/syntaxin 1 complex from M. brevicollis is structurally and functionally highly similar to the vertebrate complex, suggesting that it constitutes a fundamental step in the reaction pathway toward SNARE assembly. We thus propose that the primordial secretion machinery of the common ancestor of choanoflagellates and animals has been co-opted for synaptic roles during the rise of animals.
Xinjiang Cail, Unicellular Ca2+ Signaling Toolkit at the Origin of Metazoa, Mol Biol Evol (2008):
we demonstrate for the first time the presence of an extensive Ca2+ signaling toolkit in the unicellular choanoflagellate Monosiga brevicollis. Choanoflagellates possess homologues of various types of animal plasma membrane Ca2+ channels including the store-operated channel, ligand-operated channels, voltage-operated channels, second messenger-operated channels, and 5 out of 6 animal transient receptor potential channel families. Choanoflagellates also contain homologues of inositol 1,4,5-trisphosphate receptors. Furthermore, choanoflagellates master a complete set of Ca2+ removal systems including plasma membrane and sarco/endoplasmic reticulum Ca2+ ATPases and homologues of 3 animal cation/Ca2+ exchanger families. Therefore, a complex Ca2+ signaling toolkit might have evolved before the emergence of multicellular animals.
Alie & Manuel, The backbone of the post-synaptic density originated in a unicellular ancestor of choanoflagellates and metazoans, BMC Evol Biol (2010):
The time of origination of most post-synaptic proteins was not concomitant with the acquisition of synapses or neural-like cells. The backbone of the scaffold emerged in a unicellular context and was probably not involved in cell-cell communication. Based on the reconstructed protein composition and potential interactions, its ancestral function could have been to link calcium signalling and cytoskeleton regulation. The complex later became integrated into the evolving synapse through the addition of novel functionalities.
Liebesking etal, Evolution of sodium channels predates the origin of nervous systems in animals, PNAS (2011):
Voltage-dependent sodium channels are believed to have evolved from calcium channels at the origin of the nervous system. A search of the genome of a single-celled choanoflagellate (the sister group of animals) identified a gene that is homologous to animal sodium channels and has a putative ion selectivity filter intermediate between calcium and sodium channels. Searches of a wide variety of animal genomes, including representatives of each basal lineage, revealed that similar homologs were retained in most lineages. One of these, the Placozoa, does not possess a nervous system. We cloned and sequenced the full choanoflagellate channel and parts of two placozoan channels from mRNA, showing that they are expressed. Phylogenetic analysis clusters the genes for these channels with other known sodium channels. From this phylogeny we infer ancestral states of the ion selectivity filter and show that this state has been retained in the choanoflagellate and placozoan channels.
So from a billion years ago, nervous systems have been ready to exist when they were needed. They were needed by the combination of movement and multicellularity, in other words, animals. Nervous systems were not needed by multicellular organisms that did not move about and they were not needed by the little movers that were single-celled.