The series of events in which a stimulus from a bacterium is received and converted into a molecular signal.