# @botbuildercommunity/core

> Classes used by other (community) libraries.

Latest version **1.0.1** (published 2020-03-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @botbuildercommunity/core
pnpm add @botbuildercommunity/core
yarn add @botbuildercommunity/core
bun add @botbuildercommunity/core
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-03-26 |
| First published | 2020-03-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 251.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 125 |
| Maintainers | cloudguy_pro, imick, jamesemann, szul |

## Links

- npm: https://www.npmjs.com/package/@botbuildercommunity/core
- 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/@botbuildercommunity/core

## Dependencies (3)

- [qs](https://npm.io/package/qs.md) ^6.9.2
- [botbuilder](https://npm.io/package/botbuilder.md) ^4.8.0
- [botframework-connector](https://npm.io/package/botframework-connector.md) ^4.8.0

## Recent versions

- 1.0.1 (latest) — 2020-03-26
- 1.0.0 — 2020-03-20

## README

# BotBuilder Community Core

This package should not be used directly in your Bot Framework chatbot. Instead, it is used in other packages to minimize code repetition.

## CustomWebAdapter

The CustomWebAdapter adds two extra functions to the default `BotAdapter`. `retrieveBody` could be used to retrieve the body of a HTTP request and it will automatically serialize JSON and url-encoded content. `delay` could be used as a helper function for the delay activity.

It is possible to use the [Bot Service OAuth functionality](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-concept-authentication?view=azure-bot-service-4.0) by passing in the optional `BotFrameworkAdapterSettings` object. If you want to implement your own OAuth functionality in `YourOwnAdapter`, you could override the existing OAuth functions found in `IUserTokenProvider`. Sample code for adding OAuth to your bot can be found [here](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-authentication?view=azure-bot-service-4.0&tabs=javascript).

```typescript
import { CustomWebAdapter } from '@botbuildercommunity/core';

export class YourOwnAdapter extends CustomWebAdapter {

    protected readonly yourOwnAdapterSettings: YourOwnAdapterSettings;

    public constructor(yourOwnAdapterSettings: YourOwnAdapterSettings, botFrameworkAdapterSettings?: BotFrameworkAdapterSettings) {
        // Add optional botFrameworkAdapterSettings to enable OAuth on custom adapters
        super(botFrameworkAdapterSettings);
    }

    public async processActivity(req: WebRequest, res: WebResponse, logic: (context: TurnContext) => Promise<any>): Promise<void> {
        const body = this.retrieveBody(req);
        ...
    }

    public async sendActivities(context: TurnContext, activities: Partial<Activity>[]): Promise<ResourceResponse[]> {
        const responses: ResourceResponse[] = [];

        for (let i = 0; i < activities.length; i++) {
            const activity: Partial<Activity> = activities[i];

            switch (activity.type) {
                case 'delay':
                    await delay(activity.value);
                    responses.push({} as ResourceResponse);
                    break;
                    ...
            }
        }
    }
}
```

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