How can I trigger an event when a player interacts with a villager?

What I want to do is have it so when a player right clicks on a certain type of villager, the villager will say some stuff to them, for example "Quick, the monsters are in the dungeon!" and the player can progress the villager's speech by right clicking again. Would this be possible in 1.12.2? If not, I'll use 1.13.


Okay, found a way! For anyone wanting the same stuff, summon a villager in the spot you want, then run:

/entitydata @e[type=villager,r=5] {Offers:{Recipes:[]},NoAI:1}

then do

/scoreboard objectives add talk stat.talkToVillager

Then make repeating command blocks with

/testfor @a[score_talk_min=1,score_talk=1]

with chain command blocks going off them with tellraw commands inside. Hopefully this helps!