رفتن به محتوای اصلی

Widget SDK documentation

Once the widget is installed, the global object below is available on the page. Calls made before the widget is ready are queued.

window.Gapsoo.setUser({ name: 'Sara', email: 'sara@example.com' });
window.addEventListener('gapsoo:message:received', (e) => console.log(e.detail));

Methods

Gapsoo.open()

Open the widget.

Gapsoo.close()

Close the widget.

Gapsoo.toggle()

Open or close the widget.

Gapsoo.setUser(args)

Set the visitor's details. Filled fields are overwritten only with forceUpdate.

FieldTypeRequired
emailstring (email)No
namestringNo
aboutstringNo
phonestringNo
avatarstring (uri)No
tagsstring[]No
metadataobject[]No
forceUpdatebooleanNo

Gapsoo.getUser(callback)

Read the visitor's details. The answer comes back through a callback.

Gapsoo.setWidget(args)

Change the widget's look on this page only.

FieldTypeRequired
iconUrlstring (uri)No
cssUrlstring (uri)No
soundUrlstring (uri)No
marginRightintegerNo
marginLeftintegerNo
marginBottomintegerNo
hasIconbooleanNo
hasSoundbooleanNo
counterbooleanNo
filterWordsstring[]No

Gapsoo.getVisitorId()

The current visitor id.

Gapsoo.setVisitorId(args, callback)

Continue the same conversation on another device with the visitor id. The answer comes back through a callback.

FieldTypeRequired
—stringYes

Gapsoo.unsetVisitorId()

Forget the visitor id in this browser.

Gapsoo.sendMessage(args)

Send a message as the visitor.

FieldTypeRequired
textstringYes

Gapsoo.destroy()

Remove the widget from the page.

Events

  • gapsoo:ready — The widget is ready.
  • gapsoo:message:sent — The visitor sent a message.
  • gapsoo:message:received — A message from an operator arrived.

Buttons in messages

An operator or the API can add buttons with the code below in a message. At most 10 buttons per message.

[button title="..." action="open_url|show_message|assign|js_event|send_webhook" data="..." message_after_click="..."]  (max 10)
مستندات SDK ابزارک چت آنلاین | گپسو