Repository navigation
feat(webhooks): send live chat events to webhook subscribers - #110
Merged
Merged
Conversation
…at.ended Webhook subscribers now receive the live chat events that only workflows got before, with escalated-laravel's DispatchWebhook chat fields. The webhook form offers them. chat.message carries reply_id and author_type, never the body; chat.ended carries ended_by (agent, customer or system).
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Webhooks did not send the live chat events
chat.started,chat.assigned,chat.messageandchat.ended; only workflows ran on them (chat.transferredwas added in #109). This sends them to subscribed webhooks with escalated-laravel'sDispatchWebhookchat payloads and offers them in the webhook event list.Changes
EventVocabulary::WEBHOOK_EVENTSgains the four events (Laravel's order), so the webhook form offers them.NotificationServicelistens onescalated_chat_started,escalated_chat_accepted,escalated_chat_message,escalated_chat_ended; onedispatch_chat_event()builds the payload for all five chat events: the ticket pluschat {session_id, ticket_id, status, agent_id, department_id}, withfrom/to_*for transferred,reply_id+author_typefor message (no body),ended_byfor ended. Visitor email and chat token never leave.escalated_chat_messagepasses$author_typeas a third argument;ChatSessionService::end()takes an optional$ended_by(defaultsystem) passed as the third argument ofescalated_chat_ended. Agent end endpoint passesagent, widget end endpointscustomer, idle cleanup stayssystem(Laravel's values).WorkflowListenerregistrations widened to match (Test_Hook_Signatures).[Unreleased]. Existing webhooks are not subscribed automatically.Tests
tests/Test_Chat_Webhooks.phpdrives the real REST routes (widget/chat/start,/chat/{id}/messages,/chat/{id}/end; agent/chat/{id}/accept,/messages,/endwith an API token) and the cleanup cron, and checks delivered webhook bodies: event names, chat fields,author_type,ended_by, no email/token/body leakage, and no chat events for a webhook not subscribed to them. Failed before the change (5/6), passes after. Full suite locally: 923 tests, only the known environment-dependentTest_Ticket_Access_Migrationseparate-database case fails locally (same as on main). Pint clean.Not covered: Laravel also raises
chat.assignedwhen routing assigns an agent at chat start; here a chat routed at start fires onlychat.started(workflows behave the same way today).