addCallback

This method adds a new callback.

Example

// Callback on new conversation start
dashly.addCallback('conversation_started', function(data) {
    console.log('User started conversation with ID = ' + data.id + ', message: ' + data.body)
})

Arguments

Argument Description
topic Required. Topic. In case you want to receive a notification.
callback Required. Function being called.

When callback is being called the only argument transmitted will be a data JSON-object with additional data.

Notifications topics

topics should be set when a callback is being created (topic is an exact condition a callback should be called upon):

conversation_started

User started a new conversation.

dashly.addCallback('conversation_started', function(data) {
    // data.id - conversation ID
    // data.body - message text
    ...
})

messenger_opened

Chat opened (this topic also works if a small pop-up is shown to a user).

dashly.addCallback('messenger_opened', function(data) {
    ...
})

messenger_closed

Chat closed.

dashly.addCallback('messenger_closed', function(data) {
    ...
})

user_replied

User replied in a conversation

dashly.addCallback('user_replied', function(data) {
    // data.id - conversation ID
    // data.body - user message text
    // data.message - message ID(manual or auto), in case a user replies a manual or an auto message. Else NULL.
    ...
})

conversation_opened

conversation opened

dashly.addCallback('conversation_opened', function(data) {
    // data.id - conversation ID
    // data.message - message ID(manual or auto). Contains NULL in case it is a conversation, started by a user.
    // data.type - conversation type
    // data.parts - conversation parts
    ...
})

event_tracked

Event tracked

dashly.addCallback('event_tracked', function(data) {
    // data.id - ID of event created
    // data.event - name of event
    ...
})



In case those topics are not enough for your purposes, write to us! We like good ideas.