That can be done with an EVENT_AGGRO in the npc script in the quests folder. You would have to get to know a bit of perl (or lua) scripting. If you look at a really simple one, like Cognoggin in quests/lfaydark.
You can get lots of samples from existing quests, from the server/quests folder to use as a base for the learning process. Of course using the wiki on github helps out too.