Call forward from an agi-bin

I’m looking for a solution for redirecting incomming calls to the extension that previously called this pstn number.

I created a php agi-bin that returns something like this:

$agi->set_variable(“redir”, 1234);

Then, in the from-pstn context, I add this:

exten => s,n,GotoIf($[ “${redir}” != “” ]?from-did-direct,{$redir},1)

But it seems it is not using the $redir value but it is taking it literally. Any help on how can I get it working?

First variable syntax is right; second is wrong.