This branch is used for Vue2 only. (last version is 0.0.9) Check vue3 branch for Vue3.
This package is to replace vue-intercom which is not maintained anymore.
npm install --save @mathieustan/vue-intercom
or
yarn add @mathieustan/vue-intercomimport Vue from 'vue';
import VueIntercom from '@mathieustan/vue-intercom';
Vue.use(VueIntercom, { appId: 'your-app-id' });vue-intercom handles the injection of Intercom's script into your html and wraps calls to the Intercom API with methods and exposes them through the $intercom object in your components.
new Vue({
el: '#app',
data: () => ({
userId: 1,
name: 'Foo Bar',
email: '[email protected]',
}),
created() {
this.$intercom.shutdown();
this.$intercom.once('ready', this.bootIntercom);
},
watch: {
email(email) {
this.$intercom.update({ email });
},
},
methods: {
bootIntercom() {
this.$intercom.boot({
user_id: this.userId,
name: this.name,
email: this.email,
});
this.$intercom.show();
},
},
});You can also use Intercom as a service if you don't want to use it inside components.
import { Intercom } from '@mathieustan/vue-intercom';
const appId = 'fakeAppId';
const intercom = new Intercom({ appId });
function startIntercomMessenger (user) {
if (!intercom.ready) {
intercom.once('ready', () => rebootIntercom(user));
} else {
rebootIntercom(user);
}
}
function rebootIntercom () {
intercom.shutdown();
if (intercom.isBooted) return;
intercom.boot(user);
}You'll have access to same methods as with $intercom
Set to true once the Intercom script has been loaded.
Set to true once the Intercom boot method has been called.
Set via the onShow/onHide events.
Set via the onUnreadCountChange event.
Calls Intercom('boot'). Automatically sets the app_id unless specified in the options object.
Calls Intercom('shutdown').
Calls Intercom('update'). If the options object is set, calls Intercom('update', options)
Calls Intercom('show').
Calls Intercom('hide').
Calls Intercom('showMessages').
Calls Intercom('showNewMessage') with pre-populated content if provided.
Calls Intercom('trackEvent') with extra metadata if provided.
Calls Intercom('startTour') with extra metadata if provided.
Calls Intercom('getVisitorId').
Requires npm 12+
First, clone project & install doc dependencies :
git clone [email protected]:mathieustan/vue-intercom.git
cd vue-intercom/doc-src/
npm installThen, you need to set your VUE_APP_INTERCOM_APP_ID inside .env file.
Finally, start project :
npm run serveYou'll be able to test from this url : http://localhost:8080