AWS connect documentation change
Summary
Added documentation for WIDGET_FRAME_CLOSED custom event and expanded system event examples with implementation details
Security assessment
Changes add documentation for event handling but do not address vulnerabilities or security controls. The WIDGET_FRAME_CLOSED event documentation helps implement proper session handling but doesn't indicate a security fix.
Diff
diff --git a/connect/latest/adminguide/supported-snippet-fields.md b/connect/latest/adminguide/supported-snippet-fields.md index 68df7d51c..8c3ada163 100644 --- a//connect/latest/adminguide/supported-snippet-fields.md +++ b//connect/latest/adminguide/supported-snippet-fields.md @@ -26 +26,6 @@ Snippet field | Type | Description | Additional documentation -`registerCallback` | Object | This allows to execute callbacks for the exposed lifecycle events. | Exposed events are `'PARTICIPANT_IDLE'` , `'CHAT_ENDED'`, `'PARTICIPANT_RETURNED'`, `'PARTICIPANT_JOINED'`, `'PARTICIPANT_LEFT'`, `'CONNECTION_ESTABLISHED'`,`'CONNECTION_LOST'`, and `'AUTHENTICATION_INITIATED'`. AUTHENTICATION_INITIATED callback is executed when the contact reaches the [Authenticate Customer](./authenticate-customer.html) flow block. +`registerCallback` | Object | This allows to execute callbacks for the exposed lifecycle events. For more information, see [amazon-connect-chatjs](https://github.com/amazon-connect/amazon-connect-chatjs). | + + * System exposed events are `'PARTICIPANT_IDLE'` , `'CHAT_ENDED'`, ` 'PARTICIPANT_RETURNED'`, `'PARTICIPANT_JOINED'`, `'PARTICIPANT_LEFT'`, ` 'CONNECTION_ESTABLISHED'`, `'CONNECTION_LOST'`, and ` 'AUTHENTICATION_INITIATED'`. `AUTHENTICATION_INITIATED` callback is executed when the contact reaches the [Authenticate Customer](./authenticate-customer.html) flow block. + * Custom exposed events are `WIDGET_FRAME_CLOSED`. + + @@ -35 +40,2 @@ The following example shows how to add snippet fields to the HTML script that ad - (function(w, d, x, id){ /* ... */ })(window, document, 'amazon_connect', 'widgetId'); + (function(w, d, x, id) { /* ... */})(window, document, + 'amazon_connect', 'widgetId'); @@ -39,3 +45,42 @@ The following example shows how to add snippet fields to the HTML script that ad - 'event_Name_1' : callback(function), - 'event_Name_2' : callback(function), - ... + // Custom event example + // WIDGET_FRAME_CLOSED + /** + * This event is triggered when user clicks on the chat widget close button, + * either widget close button was clicked when error in the chat session or normally by the user. + * This event can be used for webview use cases to go back to main app + * + * @param {string} status - The reason for widget closure + * - "error_chat": Indicates the user clicked on widget close button due to an error in the chat session + * - "close_chat": Indicates the user clicked on widget close button normally by the user + */ + 'WIDGET_FRAME_CLOSED': (eventName, { status }) => { + // You can implement custom logic based on the status value(error_chat or close_chat) + if (status == "error_chat") { + // handle error chat + } else if (status == "close_chat") { + // handle close chat + } + }, + // System event example + /** + * chatDetails: { + * contactId: string, + * participantId: string, + * participantToken: string, + * } + * data: { + * AbsoluteTime?: string, + * ContentType?: string, + * Type?: string, + * ParticipantId?: string, + * DisplayName?: string, + * ParticipantRole?: string, + * InitialContactId?: string + * } + */ + 'PARTICIPANT_JOINED': (eventName, { chatDetails, data }) => { + alert(`${data.ParticipantRole} joined the chat.`); + }, + 'event_Name_3': callback(function), + 'event_Name_4': callback(function), + // ...