This is my ending of the lua script.
I'm very confused regarding who is the actor that hang up the call and how to detect side and most of all if this code can remain into my general LUA or if I have to use any hangup hook..any way, I'm pasting my code, hoping someone can help me.



originate_disposition = session:getVariable("originate_disposition");
originate_causes = session:getVariable("originate_causes");


-- is aleg hangup?
if (originate_causes ~= nil) then

last_balance = 10;
session:set_tts_params("flite", "kal");
session:speak("Credit remaining " .. last_balance .. " euros");
session:hangup();

end



-- when bleg?









On 20 November 2015 at 19:06, Voxbox.io <talk@voxbox.io> wrote:
Hi Guys,
I have some subscribers connected to my FS.
I'm assigning each one of them some credit to place outbound calls and I'm using nibblebill to update balance accordly.
I'm rather familiar with LUA, as I'm using a script to make my logic decision on who is calling, which is the remote gateway to use and the tariff to give to nibblebill before bridging the call, and so on.

Now, I would like the user to let know the remaining balance at the end of each call playing a TTS message (of course only played when the remote party hang-up)
Is this possible?
How can I know from which side the call has been disconnected and only play TTS when is the remote party?

Thank you so much, I can't find any clue in previous messages.

Cheers
Max