WidgetChatBot

WidgetChatBot

Tutti i metodi elencati sono accessibili attraverso il namespace heres.

Methods

activateTrigger(trigger)

Activate trigger using url or id.
Example
Activete trigger by url
heres('activateTrigger', {url: 'http....my_url'})

Activate trigger by id
heres('activateTrigger', {id: 3})
Parameters:
Name Type Description
trigger Object
Properties
Name Type Description
id Number
url String

close()

Close widget.
Example
heres('close')

destroy()

Destroy widget chat bot.
Example
heres('destroy')

hide()

Hide widget.
Example
heres('hide')

hideBubble()

Hide bubble.
Example
heres('hideBubble')

(async) init(argumentsopt)

Initialize the chatbot widget.
Example
await heres('init', arguments)
await heres('init', {userId: 'user-id-1234'})
arguments.integrity = crypto.createHash('sha1').update(arguments.userId + 'secret_string_124', 'binary').digest('hex') // NodeJS example
Parameters:
Name Type Attributes Description
arguments Object <optional>
Properties
Name Type Attributes Default Description
userId String <optional>
external id of user.
integrity String <optional>
sha1(arguments.userId + pepper) where pepper is a arranged secret string with Heres
code String <optional>
null code of step to start.
params Object <optional>
settings of chat.
Properties
Name Type Attributes Default Description
selector String <optional>
"body" selector where place the widget.
autoOpen Boolean <optional>
false chat starts open.
openDelay Number <optional>
wait n seconds before opening the widget.
data Object <optional>
data to send to bot (cannot use it on zendesk integration).
zendeskDisplayName String <optional>
the name visualized on zendesk chat (only zendesk use).
channel String <optional>
used for dev mode.

offEvents()

Used to remove all events handlers attached
Example
heres('offEvents')

onClose(eventFn)

Event trigged when chat is closed.
Example
heres('onClose', function () { console.log('...') })
Parameters:
Name Type Description
eventFn function Function called when the event is trigged

onEvents(eventsFn)

Attaches one or more event handlers
Example
heres('onEvents', { myEvent: function (data) { console.log('myEvent with data', data)} })
Parameters:
Name Type Description
eventsFn Object It's a object where key is the event's name and value is a function that will called when event is triggered.

onOpen(eventFn)

Event trigged when chat is opened.
Example
heres('onOpen', function () { console.log('...') })
Parameters:
Name Type Description
eventFn function Function called when the event is trigged

open()

Open widget.
Example
heres('open')

sendMsg(msg)

Send message
Parameters:
Name Type Description
msg String | Object message can be a string or object with payload and label
Properties
Name Type Description
payload String payload
label String label to show in chat.

show()

Show widget.
Example
heres('show')

showBubble(bubble, seconds)

Show bubble. You can use bubble argument to set bubble.
Example
heres('showBubble')
heres('showBubble', args)
Parameters:
Name Type Description
bubble Object
Properties
Name Type Description
message String
quickReplies Array
Properties
Name Type Description
label String
payload String
seconds Number