# botbuilder-sentimentmiddleware

> Middleware providing sentiment value for incoming messages

Latest version **1.0.6** (published 2018-09-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install botbuilder-sentimentmiddleware
pnpm add botbuilder-sentimentmiddleware
yarn add botbuilder-sentimentmiddleware
bun add botbuilder-sentimentmiddleware
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2018-09-25 |
| First published | 2018-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 23.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 125 |
| Maintainers | mareklani |
| Keywords | botbuilder, botframework, v4, chatbots, bots, sentiment, analysis, text, analytics, middleware |

## Links

- npm: https://www.npmjs.com/package/botbuilder-sentimentmiddleware
- Repository: https://github.com/BotBuilderCommunity/botbuilder-community-js
- Homepage: https://github.com/BotBuilderCommunity/botbuilder-community-js#readme
- Issues: https://github.com/BotBuilderCommunity/botbuilder-community-js/issues
- npm.io page: https://npm.io/package/botbuilder-sentimentmiddleware

## Dependencies (4)

- [botbuilder](https://npm.io/package/botbuilder.md) ^4.0.6
- [typescript](https://npm.io/package/typescript.md) ^3.1.0-rc.20180911
- [request-promise-native](https://npm.io/package/request-promise-native.md) ^1.0.5
- [@types/request-promise-native](https://npm.io/package/@types/request-promise-native.md) ^1.0.15

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2018-09-25
- 1.0.5 — 2018-09-25
- 1.0.4 — 2018-09-25
- 1.0.3 — 2018-09-21
- 1.0.2 — 2018-09-19
- 1.0.1 — 2018-09-19
- 1.0.0 — 2018-09-19

## README

# Sentiment Analysis Middleware

### Build status

| Branch | Status                                                       | Recommended NPM package version                              |
| ------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| master | [![Build status](https://api.travis-ci.org/MarekLani/botframework-sentiment-middleware-js.svg?branch=master)](https://travis-ci.org/MarekLani/botframework-sentiment-middleware-js/) | [![NPM package version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=js&type=6&v=1.0.3&x2=0)](https://www.npmjs.com/package/botbuilder-sentimentmiddleware) |

### Description
This piece of middleware will get sentiment score of each incoming message text using Cognitive Services Text Analytics API and therefore requires a key. There is a free tier which meets most demo/PoC needs.  You can get more info at https://azure.microsoft.com/en-us/services/cognitive-services/text-analytics/

The implementation detects the language of the text and get the sentiment of the same. Currently, nearly 17 languages are supported. Full list of supported languages can be seen at https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages

### Installation

Available via NPM package [botbuilder-sentimentmiddleware](https://www.npmjs.com/package/botbuilder-sentimentmiddleware/)

Install into your project using the following command in the package manager;
```
    npm install botbuilder-sentimentmiddleware --save
```

### Usage (Typescript supported)

First create sentimentAnalysisMiddleware object and add it to middleware pipeline

```typescript
const sentimentAnalysisMiddleware = new SentimentAnalysisMiddleware({textAnalyticsAzureRegion:'{e.g. westeurope}', textAnalyticsKey:'{your text analytics key}',language:'en'})

botFrameworkAdapter.use(sentimentAnalysisMiddleware);
```

Subsequently you can obtain sentiment score for incoming message in following way:

```typescript
await sentimentAnalysisMiddleware.sentimentScore(context)
```

If not used within middleware pipeline, you can still use `getSentimentScore` method to call cognitive service and obtain the sentiment score on demand.

```typescript
await sentimentAnalysisMiddleware.getSentimentScore(context)
```

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