Just did a simple test myself
Code:
GOSSIP_SHOW: GetNumGossipAvailableQuests() returns 1
QUEST_DETAIL: GetNumGossipAvailableQuests() returns 1
QUEST_FINISHED: GetNumGossipAvailableQuests() returns 1
QUEST_GREETING: GetQuestLevel(1) returns 85
QUEST_DETAIL: GetQuestLevel(1) returns 85
QUEST_FINISHED: GetQuestLevel(1) returns 85
QUEST_DETAIL: GetQuestLevel(1) returns 0, GetNumGossipAvailableQuests() returns 0
QUEST_FINISHED: GetQuestLevel(1) returns 0, GetNumGossipAvailableQuests() returns 0
I see your issue, neither functions work if there is no QUEST_GREETING or GOSSIP_SHOW event.