Live Person Takeover Integration

Overview

Dashbot enables Live Person Takeover of bots to insert a real person into a session stream, improving engagement and increasing conversions.

When viewing a live session from the Transcripts report, you can send messages as if they are coming from the bot.

In order to take over the session, you need to pause the bot, otherwise the bot will continue to respond to subsequent messages from the user.

Bot Pause

The first step is to be able to pause the bot, so that when you insert a live person, the bot does not respond.

Creat a Pause Webhook

Your webhook will recieve two fields in the body:

  • userId
    • the user id of the session to pause
    • if you send a conversation id, this will be the conversation id instead of the user id
  • paused
    • true = pause the bot
    • false = unpause the bot

While the details of the implementation may vary, at a high level, your webhook should keep track of which user sessions are paused. Whenever a new message is received, check if the session is paused for that user, and if so, stop the bot from responding.

Example

This is basic example that maintains state in memory. For a more robust solution, save the state in a database or other persistent memory store.

const pausedUsers = {}
app.post('/pause', jsonParser, (req, res) => {
  const { paused, userId } = req.body
  pausedUsers[userId] = paused
  res.send('ok')
})

And then, check the status after receiving a message:

app.post('/webhook/', jsonParser, (req, res) => {
  dashbot.logIncoming(req.body);
  if (req.body.entry){
    req.body.entry.forEach((entry) => {
      if (entry.messaging) {
        entry.messaging.forEach((event) => {
          const recipientId = event.sender.id;
          if (!pausedUsers[recipientId]) {
            // handle message if session is not paused for this userId
            [...]
          }
        }
      }
    }
  }
}

Add the Webhook URL to your Account

Go to your Account page and select ‘edit’ next to the bot you want to add a pause webhook to.

Enter the URL in the field and click ‘save’.

http://mycoolnewbot.io/pause

Live Person Takeover

To send messages as your bot, you can provide a webhook to Dashbot. It is up to you to properly handle the webhook payload and send the right message to the right user.

Creat a Webhook

Your webhook will recieve two fields in the body:

  • userId
    • the user id of the session to pause
    • in the case of a multi-user session, this is the last user id seen
  • conversationId
    • the conversation id. If you do not pass a conversationId, this will be the same as userId.
  • apiKey
    • the Dashbot API key — to let us know which of your bots to use
  • text
    • the text to send (that you entered in the text box)

The exact details of how you implement your webhook are up to you, but at a high level, with the data in this payload, you should have everyting you need to send the message to the right user or conversation.

Add the Webhook URL to your Account

Go to your Account page and select ‘edit’ next to the bot you want to add a send webhook to.

Enter the URL in the field and click ‘save’.

http://mycoolnewbot.io/liveperson

Try it out

Start a new session with your bot and open the session from the Live Transcripts report. 

Click the ‘pause’ button to stop the bot from responding.

Type a message in the form. The message will be sent as if coming from the bot.

Try typing a message to the bot as a user. The bot should not respond after the pause button has been selected.

Click ‘unpause’ to unpause the bot and return it to normal functionality.

Now if you type a message to the bot as a user, the bot should respond.

Close Menu