It doesn't know, because it's the one that secretes it. The neurotransmitter is only released if the neuron is triggered to secretes it. Calcium binds to the presynaptic neuron and only then the neurotransmitter can be released from the vesicles into the synaptic cleft.