The Talmud (Mas. Shabbat 119b) says,
Two ministering angels accompany man on the eve of the Sabbath from the synagogue to his home, one a good [angel] and one an evil [one]. And when he arrives home and finds the lamp burning, the table laid and the bed covered with a spread, the good angel exclaims, 'May it be even thus on another Sabbath [too],' and the evil angel unwillingly responds 'amen'. But if not, then the evil angel exclaims, 'May it be even thus on another Sabbath [too],' and the good angel unwillingly responds, 'amen'.
Note: Shalom Aleichem was introduced by Kabbalists in the 17th century, who wrote it in response to the foregoing midrash from the Talmud. Since it is based on the idea of communicating directly to angels, most Christians would reject the mysticism associated with the words of this song as bad theology. Nevertheless, the hauntingly beautiful melody makes it a favorite Sabbath song for many.