Feature: Customise the position of messenger (#767)
Co-authored-by: Nithin David Thomas <webofnithin@gmail.com>
This commit is contained in:
parent
94192e8184
commit
6770126de0
8 changed files with 85 additions and 12 deletions
|
@ -8,7 +8,7 @@ const runSDK = ({ baseUrl, websiteToken }) => {
|
||||||
hasLoaded: false,
|
hasLoaded: false,
|
||||||
hideMessageBubble: chatwootSettings.hideMessageBubble || false,
|
hideMessageBubble: chatwootSettings.hideMessageBubble || false,
|
||||||
isOpen: false,
|
isOpen: false,
|
||||||
position: chatwootSettings.position || 'right',
|
position: chatwootSettings.position === 'left' ? 'left' : 'right',
|
||||||
websiteToken,
|
websiteToken,
|
||||||
|
|
||||||
toggle() {
|
toggle() {
|
||||||
|
|
|
@ -31,7 +31,7 @@ export const IFrameHelper = {
|
||||||
|
|
||||||
iframe.id = 'chatwoot_live_chat_widget';
|
iframe.id = 'chatwoot_live_chat_widget';
|
||||||
iframe.style.visibility = 'hidden';
|
iframe.style.visibility = 'hidden';
|
||||||
widgetHolder.className = 'woot-widget-holder woot--hide';
|
widgetHolder.className = `woot-widget-holder woot--hide woot-elements--${window.$chatwoot.position}`;
|
||||||
widgetHolder.appendChild(iframe);
|
widgetHolder.appendChild(iframe);
|
||||||
body.appendChild(widgetHolder);
|
body.appendChild(widgetHolder);
|
||||||
IFrameHelper.initPostMessageCommunication();
|
IFrameHelper.initPostMessageCommunication();
|
||||||
|
@ -111,7 +111,7 @@ export const IFrameHelper = {
|
||||||
});
|
});
|
||||||
|
|
||||||
const closeIcon = closeBubble;
|
const closeIcon = closeBubble;
|
||||||
closeIcon.className = 'woot-widget-bubble woot--close woot--hide';
|
closeIcon.className = `woot-elements--${window.$chatwoot.position} woot-widget-bubble woot--close woot--hide`;
|
||||||
|
|
||||||
chatIcon.style.background = widgetColor;
|
chatIcon.style.background = widgetColor;
|
||||||
closeIcon.style.background = widgetColor;
|
closeIcon.style.background = widgetColor;
|
||||||
|
|
|
@ -15,7 +15,7 @@ export const notificationBubble = document.createElement('span');
|
||||||
const bodyOverFlowStyle = document.body.style.overflow;
|
const bodyOverFlowStyle = document.body.style.overflow;
|
||||||
|
|
||||||
export const createBubbleIcon = ({ className, src, target }) => {
|
export const createBubbleIcon = ({ className, src, target }) => {
|
||||||
target.className = className;
|
target.className = `${className} woot-elements--${window.$chatwoot.position}`;
|
||||||
const bubbleIcon = document.createElement('img');
|
const bubbleIcon = document.createElement('img');
|
||||||
bubbleIcon.src = src;
|
bubbleIcon.src = src;
|
||||||
target.appendChild(bubbleIcon);
|
target.appendChild(bubbleIcon);
|
||||||
|
|
|
@ -30,12 +30,29 @@ export const SDK_CSS = ` .woot-widget-holder {
|
||||||
background: #1f93ff;
|
background: #1f93ff;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
right: 20px;
|
|
||||||
bottom: 20px;
|
bottom: 20px;
|
||||||
width: 64px !important;
|
width: 64px !important;
|
||||||
height: 64px !important;
|
height: 64px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.woot-widget-bubble.woot-elements--left {
|
||||||
|
left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.woot-widget-bubble.woot-elements--right {
|
||||||
|
right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (min-width: 667px) {
|
||||||
|
.woot-widget-holder.woot-elements--left {
|
||||||
|
left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.woot-widget-holder.woot-elements--right {
|
||||||
|
right: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.woot-widget-bubble:hover {
|
.woot-widget-bubble:hover {
|
||||||
background: #1f93ff;
|
background: #1f93ff;
|
||||||
-moz-box-shadow: 0 8px 32px rgba(0, 0, 0, .4) !important;
|
-moz-box-shadow: 0 8px 32px rgba(0, 0, 0, .4) !important;
|
||||||
|
@ -53,6 +70,7 @@ export const SDK_CSS = ` .woot-widget-holder {
|
||||||
.woot--close:hover {
|
.woot--close:hover {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.woot--close:before, .woot--close:after {
|
.woot--close:before, .woot--close:after {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 32px;
|
left: 32px;
|
||||||
|
@ -62,9 +80,11 @@ export const SDK_CSS = ` .woot-widget-holder {
|
||||||
width: 2px;
|
width: 2px;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.woot--close:before {
|
.woot--close:before {
|
||||||
transform: rotate(45deg);
|
transform: rotate(45deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.woot--close:after {
|
.woot--close:after {
|
||||||
transform: rotate(-45deg);
|
transform: rotate(-45deg);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +116,6 @@ export const SDK_CSS = ` .woot-widget-holder {
|
||||||
@media only screen and (min-width: 667px) {
|
@media only screen and (min-width: 667px) {
|
||||||
.woot-widget-holder {
|
.woot-widget-holder {
|
||||||
bottom: 104px;
|
bottom: 104px;
|
||||||
right: 20px;
|
|
||||||
height: calc(85% - 64px - 20px);
|
height: calc(85% - 64px - 20px);
|
||||||
width: 400px !important;
|
width: 400px !important;
|
||||||
min-height: 250px !important;
|
min-height: 250px !important;
|
||||||
|
@ -107,5 +126,4 @@ export const SDK_CSS = ` .woot-widget-holder {
|
||||||
border-radius: 16px !important;
|
border-radius: 16px !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
window.chatwootSettings = {
|
window.chatwootSettings = {
|
||||||
hideMessageBubble: false,
|
hideMessageBubble: false,
|
||||||
|
position: 'left',
|
||||||
};
|
};
|
||||||
|
|
||||||
(function(d,t) {
|
(function(d,t) {
|
||||||
|
|
|
@ -37,4 +37,4 @@ If you are using self-hosted Chatwoot installation, please configure the Faceboo
|
||||||
|
|
||||||
**Step 7**. If you want to update the agents who have access to the inbox, you can go to Settings > Inboxes.
|
**Step 7**. If you want to update the agents who have access to the inbox, you can go to Settings > Inboxes.
|
||||||
|
|
||||||

|

|
||||||
|
|
54
docs/channels/website-sdk.md
Normal file
54
docs/channels/website-sdk.md
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
---
|
||||||
|
path: "/docs/website-sdk"
|
||||||
|
title: "Sending Information into Chatwoot"
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
Additional information about a contact is always useful, Chatwoot website SDK ensures that you can send the additional info you have about the user.
|
||||||
|
|
||||||
|
If you have installed our code on your website, SDK would expose `window.$chatwoot` object.
|
||||||
|
|
||||||
|
To hide the bubble, you can use the following setting. Please not if you use this, then you have to trigger the widget by yourself.
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.chatwootSettings = {
|
||||||
|
hideMessageBubble: false,
|
||||||
|
position: 'left', // This can be left or right
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### To trigger widget without displaying bubble
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$chatwoot.toggle()
|
||||||
|
```
|
||||||
|
|
||||||
|
### To set the user in the widget
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$chatwoot.setUser('identifier_key', {
|
||||||
|
email: 'email@example.com',
|
||||||
|
name: 'name',
|
||||||
|
avatar_url: '',
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
`setUser` accepts an identifier which can be a `user_id` in your database or any unique parameter which represents a user. You can pass email, name, avatar_url as params, support for additional parameters are in progress.
|
||||||
|
|
||||||
|
Make sure that you reset the session when the user logouts of your app.
|
||||||
|
|
||||||
|
### To set labels on the conversation
|
||||||
|
|
||||||
|
Please note that the labels will be set on a conversation, if the user has not started a conversation, then the following items will not have any effect.
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$chatwoot.addLabel('support-ticket')
|
||||||
|
|
||||||
|
window.$chatwoot.removeLabel('support-ticket')
|
||||||
|
```
|
||||||
|
|
||||||
|
### To refresh the session (use this while you logout user from your app)
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$chatwoot.reset()
|
||||||
|
```
|
|
@ -51,7 +51,7 @@ FRONTEND_URL='http://localhost:3000'
|
||||||
|
|
||||||
### Configure storage
|
### Configure storage
|
||||||
|
|
||||||
Chatwoot uses [active storage](https://edgeguides.rubyonrails.org/active_storage_overview.html) for storing attachments. The default storage option is the local storage on your server.
|
Chatwoot uses [active storage](https://edgeguides.rubyonrails.org/active_storage_overview.html) for storing attachments. The default storage option is the local storage on your server.
|
||||||
|
|
||||||
But you can change it to use any of the cloud providers like amazon s3, microsoft azure and google gcs etc. Refer [configuring cloud storage](./configuring-cloud-storage) for additional environment variables required.
|
But you can change it to use any of the cloud providers like amazon s3, microsoft azure and google gcs etc. Refer [configuring cloud storage](./configuring-cloud-storage) for additional environment variables required.
|
||||||
|
|
||||||
|
@ -104,8 +104,8 @@ You can generate `SECRET_KEY_BASE` using `rake secret` command from project root
|
||||||
|
|
||||||
### Rails Logging Variables
|
### Rails Logging Variables
|
||||||
|
|
||||||
By default chatwoot will capture `info` level logs in production. Ref [rails docs](https://guides.rubyonrails.org/debugging_rails_applications.html#log-levels) for the additional log level options.
|
By default chatwoot will capture `info` level logs in production. Ref [rails docs](https://guides.rubyonrails.org/debugging_rails_applications.html#log-levels) for the additional log level options.
|
||||||
We will also retain 1 GB of your recent logs and your last shifted log file.
|
We will also retain 1 GB of your recent logs and your last shifted log file.
|
||||||
You can fine tune these settings using the following environment variables
|
You can fine tune these settings using the following environment variables
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -113,4 +113,4 @@ You can fine tune these settings using the following environment variables
|
||||||
LOG_LEVEL=
|
LOG_LEVEL=
|
||||||
# value in megabytes
|
# value in megabytes
|
||||||
LOG_SIZE= 1024
|
LOG_SIZE= 1024
|
||||||
```
|
```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue