# bot_handoff

> Bot hand off module for the Microsoft Bot Framework. It allows you to transfer a customer from talking to a bot to talking to a human.

Latest version **1.1.7** (published 2017-06-12) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install bot_handoff
pnpm add bot_handoff
yarn add bot_handoff
bun add bot_handoff
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.7 |
| Published | 2017-06-12 |
| First published | 2017-05-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | liliankasem |
| Keywords | bot, handover, hand off, bot framework |

## Links

- npm: https://www.npmjs.com/package/bot_handoff
- Repository: https://github.com/liliankasem/Bot-HandOff
- Homepage: https://github.com/liliankasem/Bot-HandOff/tree/v.1.0.0
- Issues: https://github.com/liliankasem/Bot-HandOff/issues
- npm.io page: https://npm.io/package/bot_handoff

## Dependencies (6)

- [cors](https://npm.io/package/cors.md) 2.8.3
- [express](https://npm.io/package/express.md) ^4.14.0
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.0
- [mongoose](https://npm.io/package/mongoose.md) ^4.9.7
- [botbuilder](https://npm.io/package/botbuilder.md) ^3.7.0
- [body-parser](https://npm.io/package/body-parser.md) ^1.17.2

## Recent versions

- 1.1.7 (latest) — 2017-06-12
- 1.1.6 — 2017-06-07
- 1.1.5 — 2017-06-07
- 1.1.4 — 2017-06-05
- 1.1.3 — 2017-06-05
- 1.1.2 — 2017-06-05
- 1.1.1 — 2017-06-02
- 1.1.0 — 2017-05-26
- 1.0.4 — 2017-05-26
- 1.0.2 — 2017-05-26
- 1.0.1 — 2017-05-26
- 1.0.0 — 2017-05-26

## README

# Bot-HandOff

A common request from companies and organizations considering bots is the ability to "hand off" a customer from a bot to a human agent, as seamlessly as possible.

This project implements a framework called **Handoff** which enables bot authors to implement a wide variety of scenarios, including a full-fledged call center app, with minimal changes to the actual bot.

It also includes a very simple implementation that illustrates the core concepts with minimal configuration.

This project is in heavy flux, but is now in a usable state. However this should still be considered a sample, and not an officially supported Microsoft product.

This project is written in TypeScript.

[Source Code](https://github.com/liliankasem/Bot-HandOff/tree/v.1.0.0)

See [example folder](https://github.com/liliankasem/Bot-HandOff/tree/v.1.0.0/example) for a full bot example.

## Basic Usage

```javascript
// Imports
const express = require('express');
const builder = require('botbuilder');
const bot_handoff = require('bot_handoff');

// Setup Express Server (N.B: If you are already using restify for your bot, you will need replace it with an express server)
const app = express();
app.listen(process.env.port || process.env.PORT || 3978, '::', () => {
    console.log('Server Up');
});

// Replace this functions with custom login/verification for agents
const isAgent = (session) => session.message.user.name.startsWith("Agent");

/**
    bot: builder.UniversalBot
    app: express ( e.g. const app = express(); )
    isAgent: function to determine when agent is talking to the bot
    options: { }
        - mongodbProvider and directlineSecret are required (both can be left out of setup options if provided in environment variables.)
        - textAnalyiticsKey is optional. This is the Microsoft Cognitive Services Text Analytics key. Providing this value will result in running sentiment analysis on all user text, saving the sentiment score to the transcript in mongodb.
**/
bot_handoff.setup(bot, app, isAgent, {
    mongodbProvider: process.env.MONGODB_PROVIDER,
    directlineSecret: process.env.MICROSOFT_DIRECTLINE_SECRET,
    textAnalyiticsKey: process.env.CG_SENTIMENT_KEY
});

```

If you want the sample `/webchat` endpoint to work (endpoint for the example agent / call center), you will need to include this [`public` folder](https://github.com/liliankasem/Bot-HandOff/tree/v.1.0.0/example/public) in the root directory of your project, or replace with your own.

Required environment variables:
```
"MICROSOFT_APP_ID" : "",
"MICROSOFT_APP_PASSWORD" : "",
"MICROSOFT_DIRECTLINE_SECRET" : "",
"MONGODB_PROVIDER" : ""      
```

Optional environment variables:
```
"CG_SENTIMENT_KEY" : ""
```

## License

MIT License

---
_Source: https://npm.io/package/bot_handoff · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
