A few systems coming together here. NPCs get generated and given names. Quests get generated and assigned to NPCs. Each quest has the kind of item to get and the number to collect. The NPC’s dialogue tree adds dialogue options based on the current state of the NPC’s associated quests and other state such as whether the player has enough items in their inventory to complete the quest. Selecting the dialogue options progresses the state of the quest and removes the items from the player’s inventory.