Image copyright Getty Images Image caption Prime Minister of Canada Justin Trudeau departs a press availability at the Canadian Embassy in Washington

In 2017, Canadian Prime Minister Trudeau learned a lesson about the power of social media.

The PM's most viral tweet of the year - by far - was sent out on a January weekend, welcoming refugees to Canada.

It was retweeted 418,000 times, liked by over 768,000 Twitter users, and received widespread media coverage.

The tweet was sent out shortly after the US implemented a temporary ban on refugees and immigration from seven Muslim-majority countries - a policy that continues to be fought in US courts.

Admittedly, it's hard to gauge the impact of one tweet - many factors were at play.

But within a few months, thousands of migrants were crossing into Canada illegally at the US border.

By the end of November, 18,615 people had crossed into Canada seeking asylum.

Rival politicians and others said the widely shared message might have misled people about the ease of gaining residency.

By mid-year, Mr Trudeau's government had cooled its warm welcome.

Canada still welcomed immigrants and refugees, yes. But officials began to clarify there are laws and processes in place for people seeking asylum.

"For someone to successfully seek asylum it's not about economic migration," Mr Trudeau warned in August.

The subsequent backlog of refugee claims, the potential political fallout, and the possibility of another surge are among the challenges Mr Trudeau will face in 2018 as he heads into the final half of his four-year mandate.

Asylum seekers

The number of people crossing to Canada dropped in September and has since held steady at around 1,500 to 1,700 per month.

Media playback is unsupported on your device Media caption 'I lost all my fingers': Asylum seekers make dangerous border crossing

Janet Dench, executive director of the Canadian Council for Refugees, says Canada has successfully dealt with claims surges in the past.

"[It] doesn't necessarily need to be a challenge unless the government chooses to make it one," she says.

"And unfortunately so far, they have been failing to do the obvious things."

She says the government has yet to increase the budgets and ramp up the capacity enough for the Immigration and Refugee Board of Canada and its appeals division to meet the demand, even as claims piled up.

"Once you've developed a backlog it's difficult to work through it," Ms Dench says. "When you allow a backlog to develop, then you create conditions in which there's an incentive for people who don't need protection to make refugee claims. It's a problem then than that builds on itself."

Media playback is unsupported on your device Media caption Hundreds of migrants are illegally crossing the US border into Canada each day

There are also political ramifications that could come with another surge, says Shachi Kurl with the Angus Reid Institute, a national non-profit polling firm.

Trudeau's January tweet "isn't necessarily the sentiment being held by a lot of Canadians".

"There's a tension point" between "what a lot of people think the ideal of Canada is, versus what Canadians' true feeling are on this issue", she says.

Ethics headaches

Mr Trudeau ended 2017 in an ethics quagmire partly of his own making.

Canada's federal ethics tsar found he'd breached conflict of interest rules for tropical vacations taken on the Aga Khan's private island, including one over the 2016 Christmas break.

He told reporters this year he will vacation in Canada's Rockies instead.

Image copyright Reuters Image caption Canada's finance minister Bill Morneau has had a difficult autumn

Meanwhile, Trudeau's finance minister, Bill Morneau, is struggling with his own ethics troubles.

Morneau spent weeks under fire for not putting C$20m ($15.6m; £11.7m) of stocks in a pension management company founded by his father into a blind trust, as well as for his sponsorship of a pension bill.

He also faced problems related to the disclosure of a private villa in France.

The controversies around his personal wealth were only compounded by a badly fumbled attempt to reform small business taxes.

A mid-December poll by the Angus Reid Institute indicated that for the first time since his election, Trudeau's approval ratings had dropped below 50%.

Trudeau's ratings are still strong for a politician, but Kurl says there is "perhaps a little bit less adoration and a little bit more exasperation with the prime minister".

Kurl says the troubles challenging Trudeau's government have been mostly driven by "the follies, travails or troubles of Bill Morneau".

This year also saw the two opposition parties - the Conservatives and the NDP - elect new leaders.

"This government ran into its first real brush with organised opposition around those small business tax changes," she says.

As the two rival leaders find their feet - and if Trudeau and his ministers keep handing them easy ammunition - 2018 could also prove a rough ride.

Trade travails

By the end of 2017, hopefully optimistic feelings about the talks to modernise the North American Free Trade Agreement (Nafta) between the US, Canada, and Mexico have faded into the rearview mirror.

Image copyright Pool/Getty Images Image caption US President Donald Trump launched new Nafta talks in 2017

Canadian Chamber of Commerce president Perrin Beatty says he is "considerably more concerned now" than when the talks launched in August.

By October, the influential US Chamber of Commerce was saying it was time to "ring alarm bells" over the Nafta talks.

The business lobby group said there were "several poison pill proposals" put on the table by the US that could tank the renegotiations.

Beatty praised the Trudeau government for its efforts selling the merits of 1994 trade deal to American stakeholders.

But Beatty says the future of the trade pact "will depend on what the man in the Oval office thinks one morning when he wakes up, whether he decides that he wants to serve notice of termination or whether he wants to allow all the negotiations to continue".

As the business relationship with Canada's largest trading partner looks precarious, the Trudeau government has turned its attention to finding new clients in the Asia Pacific and China, though those negotiations have also been rocky.

Lead Nafta negotiators gather in Montreal in January for the next round of talks.