They did have plans before the film released but they didn't get the green-light until Item 47 came with home media release of The Avengers.
Disney CEO Bob Iger greenlit a television series based on S.H.I.E.L.D. at ABC after watching Item 47. - Wikipedia
But a TV show with Coulson was discussed before the film came:
“We all love Clark Gregg, there’s no doubt about that,” Whedon said. “From before we made ‘The Avengers,’ we discussed whether there was a way for him to be a part of the Marvel Universe, perhaps a part of a TV show even after his death. … The fact of the matter is, as much as we love him, now that I’m really running Marvel, I like to keep a type of artistic integrity, which means we don’t stretch the bounds of reality.”
“There was never going to be a ‘S.H.I.E.L.D.’ show without Agent Phil Coulson!” said Feige - CBR
So they didn't know if show will come or not when they filmed The Avengers but they wanted to have Coulson from the start and that's why they revived him for the show.