Alavirta joined the Russian Social Democratic Labour Party in 1906 and was elected to parliament in 1917 from the southern constituency of Häme county.
When the Red side lost the war, he fled to Soviet Russia, where he was initially the office manager of the Bui settlement established for Finnish refugees.
After the war, he fled to Soviet Russia, where he was initially the office manager of the Bui settlement established for Finnish refugees.
In Leningrad, Alavirta worked as the director of Suomalainen Kustannusosuuskunta Kirja and editor of Vapaus magazine.
In 1927, Alavirta received permission from Santeri Nuorteva to move to the Republic of Karelia, where he worked as an editor for Punainen Kartjala, published in Petrozavodsk.