Skip to content

Tawk 860rywc83 new api for connections #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Use the JavaScript API to manipulate the chat widget displayed on your website.
- [tagsUpdated](#tagsupdated)
- [unreadCountChanged](#unreadcountchanged)
- [visitor](#visitor)
- [autoStart](#autostart)
- [start](#start)
- [shutdown](#shutdown)
- [maximize](#maximize)
- [minimize](#minimize)
- [toggle](#toggle)
Expand Down Expand Up @@ -297,6 +300,41 @@ this.$tawkMessenger.visitor({

<br/>

## autoStart
If set to true, it will auto-start the Tawk socket connection for chat services. If set to false,
you will need to manually call the start API. It will not register and connect to the dashboard
if this is set to false.

```js
import TawkMessengerVue from '@tawk.to/tawk-messenger-vue-2';

Vue.use(TawkMessengerVue, {
propertyId : 'property_id',
widgetId : 'widget_id',
autoStart : false
});
```

<br/>

## start
Start the tawk socket connection.

```js
this.$tawkMessenger.start();
```

<br/>

## shutdown
End the tawk socket connection.

```js
this.$tawkMessenger.shutdown();
```

<br/>

## maximize
Maximizes the chat widget.

Expand Down
6 changes: 5 additions & 1 deletion src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class TawkMessenger {
this.propertyId = options.propertyId;
this.widgetId = options.widgetId;
this.embedId = options.embedId;
this.autoStart = options.autoStart;
this.customStyle = options.customStyle;
this.basePath = options.basePath;

Expand All @@ -41,7 +42,8 @@ class TawkMessenger {
propertyId : this.propertyId,
widgetId : this.widgetId,
embedId : this.embedId,
basePath : this.basePath
basePath : this.basePath,
autoStart : this.autoStart
});

this.init();
Expand All @@ -65,6 +67,8 @@ class TawkMessenger {
* API for calling an action on the widget
*/
mapActions() {
this.root.start = () => window.Tawk_API.start();
this.root.shutdown = () => window.Tawk_API.shutdown();
this.root.maximize = () => window.Tawk_API.maximize();
this.root.minimize = () => window.Tawk_API.minimize();
this.root.toggle = () => window.Tawk_API.toggle();
Expand Down
6 changes: 5 additions & 1 deletion src/utils/widget.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-unused-vars */

function loadScript({propertyId = '', widgetId = '', embedId = '', basePath = 'tawk.to'}) {
function loadScript({propertyId = '', widgetId = '', embedId = '', basePath = 'tawk.to', autoStart = true}) {
if (embedId.length) {
/**
* If the element with embedId as id we will create a new clement
Expand All @@ -15,6 +15,10 @@ function loadScript({propertyId = '', widgetId = '', embedId = '', basePath = 't
window.Tawk_API.embedded = embedId;
}

if (!autoStart) {
window.Tawk_API.autoStart = autoStart;
}

const script = document.createElement('script');
script.async = true;
script.src = `https://embed.${basePath}/${propertyId}/${widgetId}`;
Expand Down