Image copyright WCVB Image caption Michelle Carter, 20, is being tried in juvenile court

A 20-year-old US woman, whose boyfriend took his own life nearly three years ago, has gone on trial for allegedly urging him to kill himself.

Michelle Carter is charged with involuntary manslaughter for her role in the suicide of Conrad Roy III.

Prosecutors allege Ms Carter drove the Massachusetts 18-year-old to his death to attract sympathy.

She has asked a judge to rule on the case, rather than a jury of her peers.

"You need to do it, Conrad," Ms Carter texted him on the morning of 12 July, according to records presented by the Bristol County District Attorney's Office.

"You're ready and prepared. All you have to do is turn the generator on and you will be free and happy," she wrote.

Image copyright WCVB Image caption Mr Roy had been due to attend university in the autumn

She told him in another message: "You're finally going to be happy in heaven. No more pain. It's okay to be scared and it's normal. I mean, you're about to die."

As he expressed doubts, she kept pushing.

"I thought you wanted to do this. The time is right and you're ready … just do it babe," she said.

"No more pushing it off. No more waiting," she went on.

Mr Roy was found dead from carbon monoxide poisoning in his vehicle at a Kmart car park in Fairhaven, Massachusetts, on 13 July 2014.

Texts show he wavered in his plan to follow through with the suicide, at one point getting out of his pick-up truck.

The court heard that Ms Carter, who was then 17, replied: "Get the f*** back in the car."

After his death, she fundraised for mental health awareness and led a charity softball event in his honour.

Image copyright Facebook Image caption Ms Carter reportedly texted Mr Roy that his parents would "get over" his suicide

Mr Roy's mother, Lynn Roy, told the court on Tuesday she had no warning of her son's suicide.

She said: "I thought he was a little depressed."

On the day of his death, Mr Roy went to the seaside in Westport, Massachusetts, with his mother and sisters, according to prosecutors.

He bought his sisters ice cream, joked about bathing suits and spoke of a scholarship he had just won, while making other plans for the future.

Ms Carter sent texts to Mrs Roy after her son's death, telling her that his spirit lived on.

One text read: "I loved him, Lynn. I know I'm young, but I saw the rest of my life with him."

Other stories you may be interested in:

As arguments began on Tuesday, images of his text exchanges with Ms Carter were broadcast on the courtroom wall.

"She used Conrad as a pawn," said Assistant District Attorney Maryclare Flynn, adding that the accused had wanted to gain attention as the "grieving girlfriend".

"She talked him out of his doubts point-by-point, assured him that his family would understand why he did it, researched logistics and reassured him that he was likely to succeed, and pushed him to stop procrastinating and get on with it, mocking his hesitation," said the prosecutor.

Lawyers had requested the case be dismissed on the grounds of right to free speech.

But a juvenile court judge ruled that encouraging suicide was not protected under the US constitution.

Defence lawyer Joseph Cataldo argued that Mr Roy had been motivated to kill himself for some time, and that his depression was spurred by family troubles.

He told the court that Ms Carter had previously talked her boyfriend out of suicide attempts.

Recently unsealed documents show Mr Roy attempted to take his own life several times before, and had spent time researching methods online.

Defence lawyer Mr Cataldo said in court: "My heart goes out to the family, but this was a young man who planned this for months and months".

According to local media reports, Ms Carter had also texted Mr Roy that his parents would "get over" his suicide.

"You've hit that point and I think your parents know you've hit that point," the accused texted. "You said your mom saw a suicide thing on your computer and she didn't say anything. I think she knows it's on your mind and she's prepared for it."

She added: "They will always carry you in their hearts."

Mr Roy replied: "Aww. Thank you, Michelle."

Where to get help

If you are depressed and need to ask for help, there's advice on who to contact at BBC Advice.

From Canada or US: If you're in an emergency, please call 911. If you or someone you know is suffering with mental-health issues, call Kids Help Phone at 1-800-668-6868. If you're in the US, you can text HOME to 741741

From UK: Call Samaritans on 116123 or Childline on 0800 1111