But I think there is a simple solution: I just have to use ESL to watch for CHANNEL_ANSWER or set execute_on_answer=lua somescript.lua" and set the filename inside the script.
That works. You could also use execute_extension and set the filename there, since the "set" app wouldn't run until the extension is executed.