It's impossible to initiate an NPC dialog from your code, but you can automate your interaction with one. Here is my fast-n-dirty solution I actually use:
/Interface/AddOns/Passenger/Passenger.lua
Code:
Passenger = CreateFrame('Frame')
Passenger:SetScript('OnEvent', function()
if event ~= 'GOSSIP_SHOW' then return end
if GetGossipActiveQuests() or GetGossipAvailableQuests() then return end
function pairs2(t)
local index = nil
return function()
index, value1 = next(t, index)
if ( index ) then
index, value2 = next(t, index)
return index / 2, value1, value2
end
end
end
GetGossipOptions()
for index, title, type in pairs2({GetGossipOptions()}) do
if type == 'taxi' then
SelectGossipOption(index)
return
end
end
end)
Passenger:RegisterEvent('GOSSIP_SHOW')
/Interface/AddOns/Passenger/Passenger.toc:
Code:
## Interface: 20003
## Title: Passenger
## Notes: one click flight path selection
## Version: 0.1
## DefaultState: enabled
## X-Category: Interface
Passenger.lua