Minecraft wiki entry for dialogue, associated text: dialogue change
Changes the content of the targeted NPC according to the targeted scene, including dialogue, commands, and name.
This will close the dialogue box and update for the next time the NPC is interacted.
The content can be updated on a per-player basis. If no player is targeted, the dialogue will update for all players.
Syntax:
dialogue change <npc: target> <sceneName: string> [player: target]
Example: Change the dialogue of an NPC with tag "ducky" into scene "duck_intro" toward the initiator.
dialogue change @e[type=npc, tag=ducky] ducky_intro @initiator