Lua Code:
local frame = CreateFrame'Frame'
frame:RegisterEvent'PARTY_INVITE_REQUEST'
frame:SetScript('OnEvent', function(self, event, name)
SendChatMessage('Some message to reply here', 'WHISPER', nil, name)
StaticPopup1Button2:Click()
end)
No need to hook stuff