Skip to content

Commit 28ec68f

Browse files
authored
Update chat docs with new options and methods (#151)
* Update chat docs with new options and methods * Update methods.mdx
1 parent 7c9b895 commit 28ec68f

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

_snippets/chat/customization.mdx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ Plain.init({
4343
// When specified, launcher will be hidden by default.
4444
embedAt: '#embed',
4545

46+
// Optional. Hides the 'Powered by Plain' branding
47+
hideBranding: false,
48+
4649
// Optional. The color scheme of the Chat, is either 'auto', 'light', or 'dark'
4750
// 'auto' uses the user's browser preference to decide between light and dark mode (default: 'auto')
4851
theme: 'light',
@@ -63,14 +66,21 @@ Plain.init({
6366
alt: 'An example logo';
6467
};
6568

69+
// Optional. Position of the chat widget when it is floating.
70+
// See https://developer.mozilla.org/en-US/docs/Web/CSS/position for more information - only bottom and right are supported
71+
position: {
72+
right: '10px',
73+
bottom: '10px',
74+
}
75+
6676
// Optional. Allows you to set fields for the threads which are created from chats
6777
threadDetails: {
6878
// See the data model documentation [asdasd](/chat/customization#all-threads) for more information on these fields
6979
};
7080

7181
// Optional. Lets you customize the buttons which are used to start a new chat on the intro screen
7282
chatButtons: [
73-
// See the chat buttons documentation (https://localhost:3000/chat/customization#chat-buttons) for more information on these fields
83+
// See the chat buttons documentation for more information on these fields
7484
];
7585
});
7686
```

_snippets/chat/methods.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
```typescript
2+
// This takes the same arguments as Plain.init. It will update the chat widget in-place with the new configuration.
3+
// Only top-level fields are updated, nested fields are not merged.
4+
Plain.update({ ... });
5+
6+
// This takes the same arguments as `customerDetails` in Plain.init.
7+
// This will update just the customer details in the chat widget. This may be useful if you have asynchronous authentication state
8+
Plain.setCustomerDetails({ ...})
9+
10+
// Opens and closes the widget if using the default, floating mode
11+
Plain.open();
12+
Plain.close();
13+
14+
// These are event listeners that will be fired when the chat widget is opened or closed respectively
15+
// These return a function that can be called to remove the listener
16+
Plain.onOpen(() =>{
17+
// Opened
18+
});
19+
Plain.onClose(() => {
20+
// Closed
21+
});
22+
23+
// Returns whether or not the chat widget is initialized
24+
Plain.isInitialized();
25+
26+
// This returns an array with debug logs that have been collected by the chat widget
27+
// This is useful if you are contacting Plain support with an issue regarding the chat widget
28+
// This will redact sensitive information such as customer details
29+
Plain.exportDebugLogs();
30+
```

chat/customization.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,11 @@ Similar to chat buttons, chat forms allow you to set fields on the thread when t
5959
<Accordion title="Chat forms code">
6060
<Snippet file="chat/chat-forms.mdx" />
6161
</Accordion>
62+
63+
### Additional methods
64+
65+
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.
66+
67+
<Accordion title="Chat forms code">
68+
<Snippet file="chat/methods.mdx" />
69+
</Accordion>

0 commit comments

Comments
 (0)