# botbuilder-calling-processor

> Calling processor for Bot Framework incoming calling webhook

Latest version **0.0.1** (published 2019-05-01) · 0 weekly downloads

## Install

```sh
npm install botbuilder-calling-processor
pnpm add botbuilder-calling-processor
yarn add botbuilder-calling-processor
bun add botbuilder-calling-processor
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-05-01 |
| First published | 2019-05-01 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 21.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Wictor Wilén |
| Maintainers | wictorwilen |
| Keywords | microsoft-teams, msteams, botbuilder, botbuilder-extension |

## Links

- npm: https://www.npmjs.com/package/botbuilder-calling-processor
- npm.io page: https://npm.io/package/botbuilder-calling-processor

## Dependencies (4)

- [express](https://npm.io/package/express.md) ^4.16.4
- [botbuilder](https://npm.io/package/botbuilder.md) ^4.3.4
- [ms-rest-js](https://npm.io/package/ms-rest-js.md) ^1.0.1
- [@types/express](https://npm.io/package/@types/express.md) ^4.16.1

## Recent versions

- 0.0.1 (latest) — 2019-05-01

## README

# Calling processor for Bot Framework incoming calling webhook

[![npm version](https://badge.fury.io/js/botbuilder-calling-processors.svg)](https://badge.fury.io/js/botbuilder-calling-processors)

 | @master | @preview |
 :--------:|:---------:
 [![Build Status](https://travis-ci.org/wictorwilen/botbuilder-calling-processors.svg?branch=master)](https://travis-ci.org/wictorwilen/botbuilder-calling-processors)|[![Build Status](https://travis-ci.org/wictorwilen/botbuilder-calling-processors.svg?branch=preview)](https://travis-ci.org/wictorwilen/botbuilder-calling-processors)


## Sample usage

``` TypeScript
import * as _Request from "request";
import uuidv1 = require("uuid/v1");
import { IncomingCallProcessor, IncomingCallProcessorConfig, IncomingCallHandler, call, resultInfo } from "botbuilder-calling-processor";
import express = require("express");

private callProcessor: IncomingCallProcessor;
@BotCallingWebhook("/api/calling")
public async onIncomingCall(req: express.Request, res: express.Response, next: express.NextFunction) {
    log("/api/calling ping");
    if (!this.callProcessor) {
        const handler: IncomingCallHandler = {
            onIncomingCall: async (resource: string, resourceData: call): Promise<string> => {
                log("Incoming call");
                return new Promise<string>(async (resolve, reject) => {
                    const token = await getAuthToken();
                    const clientContext = uuidv1();
                    _Request({
                        method: "POST",
                        uri: `https://graph.microsoft.com/beta${resource}/answer`,
                        headers: {
                            "content-type": "application/json",
                            "authorization": `Bearer ${token}`
                        },
                        body: JSON.stringify({
                            callbackUri: `https://${process.env.HOSTNAME}/api/calling`,
                            acceptedModalities: ["audio", "video"],
                            mediaConfig: {
                                "@odata.type": "#microsoft.graph.serviceHostedMediaConfig",
                                "preFetchMedia": [
                                    {
                                        uri: `https://${process.env.HOSTNAME}/assets/audio1.wav`,
                                        resourceId: "1D6DE2D4-CD51-4309-8DAA-70768651088E"
                                    }
                                ] 
                            }
                        })
                    }, async (error: any, response: any, body: any) => {
                        if (response.statusCode === 202) {
                            log(`Call answered!`);
                            resolve(clientContext); 
                        } else {
                            reject(`Invalid response from Microsoft Graph: ${response.status}`);
                        }
                    });
                });
            },
            onCallTerminated: (resource: string, result: resultInfo): Promise<void> => {
                log("Call termindated");
                return Promise.resolve();
            }
        };
        this.callProcessor = new IncomingCallProcessor(handler);
    }
    this.callProcessor.process(req, res);
}

## License

Copyright (c) Wictor Wilén. All rights reserved.

Licensed under the MIT license.

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