The easiest method of altering npcs is by hand, the only way it can be ensured to be done correctly. For a standard NPC modification (NON-Shop) you simply have to edit the lua for said npc or create an lua for it, then change it's contact script to the lua function you desire and viola.
For shops it a hair more complex:
You'll need:
Lua to control NPC Dialouge + Shop List
Corresponding Market entries in MarketResource
Change NPC contact_script to desired lua function
Hope this helped.