Lua Code:
local f=CreateFrame("frame")
f:RegisterEvent("GOSSIP_SHOW")
f:SetScript("OnEvent",function()
-- get the npc id from its guid
local _,_,_,_,_,npc=strsplit("-",(UnitGUID("npc")) or "")
-- its a string because it just came from a string
if npc=="135614" then -- wowhead.com/npc=135614
-- first argument is the ordered number of the gossip window
-- in this case, 2 would select "stay awhile and listen"
-- second argument is when a gossip option pops up a box
-- that needs input, currently only used to interact with
-- the Tyrael's Hilt npc or Landro Longshot
-- third argument skips any possible confirmation dialog
-- that the gossip option may generate
C_GossipInfo.SelectOption(1,"",true)
end
end)