How to use the @botonic/core.HandOffBuilder function in @botonic/core

To help you get started, we’ve selected a few @botonic/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hubtype / botonic / packages / botonic-cli / templates / handoff / src / actions / transfer-agent.js View on Github external
/*
      Uncomment the lines below before deploying the bot to Hubtype
      in order to test the getOpenQueues call for 'Customer Support'.
    */
    // let openQueues = await getOpenQueues(session)
    let agentEmail = ''
    try {
      agentEmail = (await getAvailableAgents(
        session,
        'HUBTYPE_DESK_QUEUE_ID'
      )).filter(agent => agent == 'agent-name@hubtype.com')[0]
    } catch (e) {}

    let isHandOff = false
    // if (openQueues.queues.indexOf('Customer Support') !== -1) {
    let handOffBuilder = new HandOffBuilder(session)
    handOffBuilder.withQueue('HUBTYPE_DESK_QUEUE_ID')
    handOffBuilder.withAgentEmail('agent-1@hubtype.com')
    handOffBuilder.withOnFinishPath('thanks-for-contacting') // or handOffBuilder.withOnFinishPayload('thanks-for-contacting')
    handOffBuilder.withCaseInfo(
      'This is some case information that will be available in the new created case'
    )
    handOffBuilder.withNote(
      'This is a note that will be attached to the case as a reminder'
    )
    await handOffBuilder.handOff()

    isHandOff = true
    // }
    return { isHandOff }
  }