From acbd5a5eeace6459ba88e73d5af108f3c74db609 Mon Sep 17 00:00:00 2001 From: Jordan Drake Date: Mon, 9 Dec 2024 17:39:16 +0000 Subject: [PATCH] Update chat docs with new options and methods --- _snippets/chat/customization.mdx | 12 +++++++++++- _snippets/chat/methods.mdx | 30 ++++++++++++++++++++++++++++++ chat/customization.mdx | 8 ++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 _snippets/chat/methods.mdx diff --git a/_snippets/chat/customization.mdx b/_snippets/chat/customization.mdx index ef166c1..005e390 100644 --- a/_snippets/chat/customization.mdx +++ b/_snippets/chat/customization.mdx @@ -43,6 +43,9 @@ Plain.init({ // When specified, launcher will be hidden by default. embedAt: '#embed', + // Optional. Hides the 'Powered by Plain' branding + hideBranding: false, + // Optional. The color scheme of the Chat, is either 'auto', 'light', or 'dark' // 'auto' uses the user's browser preference to decide between light and dark mode (default: 'auto') theme: 'light', @@ -63,6 +66,13 @@ Plain.init({ alt: 'An example logo'; }; + // Optional. Position of the chat widget when it is floating. + // See https://developer.mozilla.org/en-US/docs/Web/CSS/position for more information - only bottom and right are supported + position: { + right: '10px', + bottom: '10px', + } + // Optional. Allows you to set fields for the threads which are created from chats threadDetails: { // See the data model documentation [asdasd](/chat/customization#all-threads) for more information on these fields @@ -70,7 +80,7 @@ Plain.init({ // Optional. Lets you customize the buttons which are used to start a new chat on the intro screen chatButtons: [ - // See the chat buttons documentation (https://localhost:3000/chat/customization#chat-buttons) for more information on these fields + // See the chat buttons documentation for more information on these fields ]; }); ``` diff --git a/_snippets/chat/methods.mdx b/_snippets/chat/methods.mdx new file mode 100644 index 0000000..0e74d6e --- /dev/null +++ b/_snippets/chat/methods.mdx @@ -0,0 +1,30 @@ +```typescript +// This takes the same arguments as Plain.init. It will update the chat widget in-place with the new configuration. +// Only top-level fields are updated, nested fields are not merged. +Plain.update({ ... }); + +// This takes the same arguments as `customerDetails` in Plain.init. +// This will update just the customer details in the chat widget. This may be useful if you have asynchronous authentication state +Plain.setCustomerDetails({ ...}) + +// Opens and closes the widget if using the default, floating mode +Plain.open(); +Plain.close(); + +// These are event listeners that will be fired when the chat widget is opened or closed respectively +// These return a function that can be called to remove the listener +Plain.onOpen(() =>{ + // Opened +}); +Plain.onClose(() => { + // Closed +}); + +// Returns whether or not the chat widget is initialized +Plain.isInitialized(); + +// This returns an array with debug logs that have been collected by the chat widget +// This is useful if you contacting Plain support with an issue regarding the chat widget +// This will redact sensitive information such as customer details +Plain.exportDebugLogs(); +``` diff --git a/chat/customization.mdx b/chat/customization.mdx index bcd70bf..333bafe 100644 --- a/chat/customization.mdx +++ b/chat/customization.mdx @@ -59,3 +59,11 @@ Similar to chat buttons, chat forms allow you to set fields on the thread when t + +### Additional methods + +We provide additional methods on the Plain object to provide more control over the chat widget. This may be helpful to keep the chat widget in-sync with your existing application state. + + + + \ No newline at end of file