When the war broke out, Werfel served in the Austro-Hungarian Army on the Russian front. He was in Signals, as a telephone operator. He seems to have had ample time to write: poems, plays, and letters date from this period. He experimented with writing about various religions, including ancient Egypt and modern occultism. His interest in Christian themes alienated some of his fellow Jews. But his friend Martin Buber supported him, and published a sequence of poems from Werfel’s wartime manuscript Der Gerichtstag (Judgment Day, published in 1919) in his monthly journal, Der Jude (The Jew).
In summer 1917, Werfel left the frontline and joined the Military Press Bureau in Vienna, where other notable Austrian writers were working as propagandists, including Robert Musil himself, Rilke, Von Hofmannsthal and Frank Biel. This is when he met and fell in love with Anna Mahler, whose husband Walter Gropius was still on the Russian front.
This information comes from Wikipedia.