Workers and businesses need to come together for a conversation about what the future of work should look like, U.S. Labor Secretary Marty Walsh said Wednesday.

In a speech he described as somewhat of a homecoming, the former Boston mayor spoke to a crowd of labor leaders and state and city officials about what workers want as the country navigates changes from the COVID-19 pandemic, his approach while in City Hall, and recent negotiations that averted a freight rail strike.

Rail carriers and union officials met with Walsh earlier this month for a marathon 20-hour negotiating session, striking a tentative deal hours before the deadline to avoid a work stoppage. Walsh said the process was about building trust after two years of failed talks.

“Our freight rail system would have come to a grinding halt,” Walsh said during a forum hosted by the State House News Service and MASSterList. “That would have caused devastation to the U.S. economy and untold harm from loss of food, energy, health products to communities and also commuter rail, quite honestly, that was going to be impacted by it.”

Walsh, who led the building trades council in Boston before he was elected as a state representative and then mayor, said that as people are reevaluating what they want out of work after nearly three years of the pandemic, many are more interested in unions because they’re looking for respect and better opportunities.

Workers are expecting and demanding more from their employers, Walsh said. He said the essential workers who were celebrated during the early days of the COVID-19 pandemic cannot be forgotten, pointing to the grocery store and electric company workers now preparing for a hurricane in Florida.

“Both labor and business have to have a conversation about what the future of the workplace is, and how do we move forward in a positive way,” Walsh said. He said that means both sides working together to adapt to new environments.

Walsh said that when he was running for mayor in 2013, his labor background sparked some concern among business leaders who worried he wouldn’t respect their point of view. He said “ran City Hall like a business" and tried to bring labor and business together to advance new development, affordable housing and jobs while investing new tax revenues into public spaces like libraries and parks.

“We didn’t bloat the payroll,” he said. “What we did is we put that money back into our economy.”

After his speech, Walsh took questions from reporters on topics including the MBTA and his political future.

Walsh said officials in Massachusetts need to continue investing in public transit. In the wake of the high-profile 30-day shutdown of the Orange Line, he said the system as a whole "needs more than a month of work" and that hopefully the federal infrastructure law passed earlier this year can provide some resources.

"We need to get confidence back in the system," he said. "And having some of those federal dollars will help the governor and the next governor move that project along."

As far as his own future, Walsh says he has "no idea" what's next after serving in President Joe Biden's administration.

"I wasn't really expecting this, being called by the president to be secretary of labor," Walsh said. "I was getting ready to gear up to run for reelection for mayor of Boston, and this came. I really don't think that far down the road because I didn't really even think about what was next after mayor, so I'll just take this a day at a time."