3.13.3 • Published 9 months ago

@inconvo/chat-client v3.13.3

Weekly downloads
76
License
-
Repository
-
Last release
9 months ago

Inconvo chat client

Loads an Inconvo chat on any website.

Installation

npm install @inconvo/chat-client

Usage

Import library

import * as inconvoChat from '@inconvo/chat-client';
//or
const inconvoChat = require('@inconvo/chat-client');

Create client

//synchronously
await inconvoChat.createClient({
    appCode: '{app-code}',
});

//or asynchronously
inconvoChat
    .createClient({
        appCode: '{app-code}',
    })
    .then(() => {
        console.log('loaded');
    });

Start a convo

yc.startChat({
    channel: 'channel-slug',
    convo: 'convo-id',
});

or

<button onclick="yc.startChat({channel: 'channel-slug', convo: 'convo-id'})">Start Convo</button>

Subscribe to an event

chatWidget.addEventListener('openLink', (action) => {});

Unsubscribe from an event

chatWidget.removeEventListener('openLink', (action) => {});

API

createClient({options})

Creates a chat client.

options

OptionTypeRequiredDefaultDescription
appCodestringyes--App code provided by YouGov Chat
appKeystringno--App key provided by YouGov Chat
appSecretstringno--App secret provided by YouGov Chat
modestringno'sidebar'sidebar - opens chat in the right hand side of the window, or floating - creates a floating action button which can be clicked to start a chat or full-screen - the chat window covers the full page or host - it doesn't add button to the screen and doesn't set the position of the chat window, it can be configurable from the host channel-view - opens chat in single channel view
moduleNamestringno'yc'The name of the object that will be available to use once the client is created
channelstringno--if provided, opens a chat for this channel (default convo if convo is not provided) once the client is created
convostringno--if provided, opens a chat for this channel/convo once the client is created
standalonebooleannotrueIt determines that the chat widget completely integrated to the website. Eg. instead of handling links in the chat widget it emits events.
showBubblebooleannofalseIt determines if the chat widget will show bubble controls or not.
closablebooleannotrueIt determines if the chat widget should close on outside click.
onInitfunctionno--if provided, executes this function once the client is created
onEventfunctionno--if provided, executes this function once an event is triggered
topicstringno--if provided, start chat won't require a convo or channel, it will start with the first available convo with the specified topic
countryCodestringno--if provided, it will filter the topics with country code

events

Event nameTriggerData
userSubscribeuser submits their email address in the subscribe messageObject containing: channelSlug, convoId (if available)
openLinkuser clicks to a link in a messageaction
sendReplyuser replies to a questionObject containing: question and answer

startChat({options})

Opens a chat window.

options

OptionTypeRequiredDescription
channelstring / objectyes*pass the channel slug and the widget will load the channel or pass the channel object directly (default convo if convo is not provided)
convostringnoopens a chat for this channel/convo

* if a topic is provided in the createClient method, channel won't be mandatory

setConvo({options})

Sets the client channel/convo. This is useful for the floating mode.

options

OptionTypeRequiredDescription
channelstringyessets the client's channel (default convo if convo is not provided)
convostringnoset's the client's convo

changeMode(mode)

Changes the mode at runtime.

options

OptionTypeRequiredDescription
modestringyesfloatingsidebarfull-screenhostchannel-view

getConvosByTopic

This method returns with an array of convos filtered by topic id and country code.

usage

import { getConvosByTopic } from  "@inconvo/chat-client";

const convos = await getConvosByTopic('topic-id', 'country-code');

parameters

ParametersTypeRequiredDescription
TopicIdstringyesYouGov Topic ID
CountryCodestringnoIt filters the topics
3.13.2

10 months ago

3.13.1

10 months ago

3.13.3

9 months ago

3.11.3

1 year ago

3.12.0

1 year ago

3.12.0-beta.1

1 year ago

3.12.0-beta.2

1 year ago

3.12.0-beta.0

1 year ago

3.13.0

1 year ago

3.11.2

2 years ago

3.11.0

2 years ago

3.11.1

2 years ago

3.10.15

2 years ago

3.10.13

2 years ago

3.10.14

2 years ago

3.10.11

2 years ago

3.10.6

2 years ago

3.10.9

2 years ago

3.10.8

2 years ago

3.9.1

2 years ago

3.9.0

2 years ago

3.10.1

2 years ago

3.8.0

2 years ago

3.7.1

2 years ago

3.10.0

2 years ago

3.7.0

2 years ago

3.6.0

2 years ago

3.5.1

2 years ago

3.10.2

2 years ago

3.5.0

2 years ago

3.4.0

2 years ago

3.2.2

2 years ago

3.3.0

2 years ago

3.2.1

2 years ago

3.2.0

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.2.5

2 years ago

3.2.4

2 years ago

3.3.2

2 years ago

3.2.3

2 years ago

3.0.8

2 years ago

3.0.7

2 years ago

3.0.6

2 years ago

1.0.0-beta.2

3 years ago

0.1.0-alpha.16

4 years ago

0.1.0-alpha.15

4 years ago

0.1.0-alpha.14

4 years ago

0.1.0-alpha.13

4 years ago

0.1.0-alpha.12

4 years ago

0.1.0-alpha.11

4 years ago

0.1.0-alpha.10

4 years ago

0.1.0-alpha.9

4 years ago

0.1.0-alpha.7

4 years ago

0.1.0-alpha.6

4 years ago

0.1.0-alpha.5

4 years ago

0.1.0-alpha.4

4 years ago

0.1.0-alpha.3

4 years ago

0.1.0-alpha.2

4 years ago

0.1.0-alpha.1

4 years ago

0.1.0-alpha.0

4 years ago