indie-widget-chat
v0.11.0
Published
## Features - Multi Type and Multi Profile for Seller type user. - Product and Order chat content. - Send Media (Image), Order, Promotion (soon).
Downloads
35
Readme
Indie Widget Chat - IMCeria
Features
- Multi Type and Multi Profile for Seller type user.
- Product and Order chat content.
- Send Media (Image), Order, Promotion (soon).
Tech Stack
Installation
Install Indie Widget Chat via npm.
npm install indie-widget-chat
to add this widget to your app you can add this specific tag below.
<indie-widget-chat id="widget_chat" ref="refChat"></indie-widget-chat>
API
Prequisites
First of all to using this widget you need to initialize it first. Indie Widget Chat accept two arguments which is options
and callback
.
_init(_options = {}, cb = (_obj: any) => {})
at least you need to send the options
argument that should be exactly look like this :
const options = {
envProduction: _boolean_,
credential: _string_,
headUrl: _string_,
tokenUser: _string_,
tokenChamo: _string_
}
envProduction
: (Boolean | true/false) taken from app deploy state.credential
: (String) from which platform this widget is used.headUrl
: (String)* which head url this app will going to use to fetch the data.(*)
seller
: for Seller Platform.pos
: for POS Platform.whitelabel
: for Whitelabel platform.tokenUser
: (String) token user from SSO.tokenChamo
: (String) token chamo from Chamo.
init()
You can do by directly accessing the dom itself.
document.getElementById('widget_chat').init(_firstArg, _secondArg)
attachChatContent()
You can send attachment using the by sending specific payload along with it's selected data (Product / Order / Promotion) to attachChatContent
function. See the details below.
const data: {
config: {
type: _string_,
profile_type: _integer_,
target_id: _string,
target_type: _integer_
},
payload: {
...attachedContentData
}
}
type
: (String) attached content type (product
,order
,promotion
).profile_type
: (Integer) what kind of user this chat represent (0
for User/Whitelabel,1
for Staff,2
for Brand,3
for Branch/Store).target_id
: (String) reference_id/user_id of targeted user.target_type
: (String) to what kind of user this chat is send (0
for User/Whitelabel,1
for Staff,2
for Brand,3
for Branch/Store).attachedContentData
: (Object) attached content.
Then proceed to attach content to chat, see example below.
document.getElementById('widget_chat').attachChatContent(data)