@builderbot/provider-twilio 0.1.3-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/index.cjs +30187 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/server.d.ts +51 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/types.d.ts +29 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +56 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ProviderClass } from '@builderbot/bot';
|
|
2
|
+
import { Vendor } from '@builderbot/bot/dist/provider/providerClass';
|
|
3
|
+
import { BotContext, BotCtxMiddlewareOptions, SendOptions } from '@builderbot/bot/dist/types';
|
|
4
|
+
import twilio from 'twilio';
|
|
5
|
+
|
|
6
|
+
import { TwilioWebHookServer } from './server';
|
|
7
|
+
import { ITwilioProviderOptions, TwilioRequestBody } from './types';
|
|
8
|
+
declare class TwilioProvider extends ProviderClass {
|
|
9
|
+
http: TwilioWebHookServer;
|
|
10
|
+
vendor: Vendor<twilio.Twilio>;
|
|
11
|
+
private vendorNumber;
|
|
12
|
+
private publicUrl;
|
|
13
|
+
constructor({ accountSid, authToken, vendorNumber, publicUrl }: ITwilioProviderOptions);
|
|
14
|
+
private busEvents;
|
|
15
|
+
private sendMedia;
|
|
16
|
+
private sendButtons;
|
|
17
|
+
private listenOnEvents;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param port
|
|
21
|
+
* @param opts
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
initHttpServer: (port: number, opts: Pick<BotCtxMiddlewareOptions, 'blacklist'>) => void;
|
|
25
|
+
sendMessage: (number: string, message: string, options?: SendOptions) => Promise<any>;
|
|
26
|
+
saveFile: (ctx: Partial<TwilioRequestBody & BotContext>, options?: {
|
|
27
|
+
path: string;
|
|
28
|
+
}) => Promise<string>;
|
|
29
|
+
}
|
|
30
|
+
export { TwilioProvider };
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAS,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,6CAA6C,CAAA;AACpE,OAAO,EAAE,UAAU,EAAoB,uBAAuB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAG/G,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAGnE,cAAM,cAAe,SAAQ,aAAa;IAC/B,IAAI,EAAE,mBAAmB,CAAA;IACzB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACpC,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,SAAS,CAAQ;gBAEb,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,SAAc,EAAE,EAAE,sBAAsB;IAO3F,OAAO,CAAC,SAAS;YAmBH,SAAS;YA+BT,WAAW;IAUzB,OAAO,CAAC,cAAc,CAKrB;IAED;;;;;OAKG;IACH,cAAc,SAAU,MAAM,QAAQ,KAAK,uBAAuB,EAAE,WAAW,CAAC,UAiB/E;IAED,WAAW,WAAkB,MAAM,WAAW,MAAM,YAAY,WAAW,KAAG,QAAQ,GAAG,CAAC,CAWzF;IAED,QAAQ,QAAe,QAAQ,iBAAiB,GAAG,UAAU,CAAC,YAAY;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAG,QAAQ,MAAM,CAAC,CAS3G;CACJ;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { BotCtxMiddleware } from '@builderbot/bot/dist/types';
|
|
3
|
+
import { EventEmitter } from 'node:events';
|
|
4
|
+
import { Polka } from 'polka';
|
|
5
|
+
|
|
6
|
+
import type { TwilioProvider } from './';
|
|
7
|
+
import { TwilioPayload } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Encargado de levantar un servidor HTTP con una hook url
|
|
10
|
+
* [POST] /twilio-hook
|
|
11
|
+
*/
|
|
12
|
+
declare class TwilioWebHookServer extends EventEmitter {
|
|
13
|
+
server: Polka;
|
|
14
|
+
port: number;
|
|
15
|
+
constructor(twilioPort: number);
|
|
16
|
+
/**
|
|
17
|
+
* Mensaje entrante
|
|
18
|
+
* emit: 'message'
|
|
19
|
+
* @param req
|
|
20
|
+
* @param res
|
|
21
|
+
*/
|
|
22
|
+
private incomingMsg;
|
|
23
|
+
/**
|
|
24
|
+
* Manejar los local media como
|
|
25
|
+
* C:\\Projects\\bot-restaurante\\tmp\\menu.png
|
|
26
|
+
* para que puedas ser llevar a una url online
|
|
27
|
+
* @param req
|
|
28
|
+
* @param res
|
|
29
|
+
*/
|
|
30
|
+
private handlerLocalMedia;
|
|
31
|
+
/**
|
|
32
|
+
* Construir HTTP Server
|
|
33
|
+
* @returns Polka instance
|
|
34
|
+
*/
|
|
35
|
+
protected buildHTTPServer(): Polka;
|
|
36
|
+
/**
|
|
37
|
+
* Iniciar el servidor HTTP
|
|
38
|
+
*/
|
|
39
|
+
start(vendor: BotCtxMiddleware, port?: number): void;
|
|
40
|
+
stop(): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param inHandleCtx
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
declare const inHandleCtx: <T extends Pick<TwilioProvider, "sendMessage" | "vendor"> & {
|
|
48
|
+
provider: TwilioProvider;
|
|
49
|
+
}>(ctxPolka: (bot: T, req: any, res: any) => Promise<void>) => (req: any, res: any) => any;
|
|
50
|
+
export { TwilioWebHookServer, TwilioPayload, inHandleCtx };
|
|
51
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAG7D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAc,EAAc,KAAK,EAAE,MAAM,OAAO,CAAA;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,IAAI,CAAA;AACxC,OAAO,EAAqB,aAAa,EAAE,MAAM,SAAS,CAAA;AAK1D;;;GAGG;AACH,cAAM,mBAAoB,SAAQ,YAAY;IACnC,MAAM,EAAE,KAAK,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;gBAEP,UAAU,EAAE,MAAM;IAM9B;;;;;OAKG;IACH,OAAO,CAAC,WAAW,CAwClB;IAED;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB,CAWxB;IAED;;;OAGG;IACH,SAAS,CAAC,eAAe,IAAI,KAAK;IAQlC;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM;IAoB7C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAWxB;AAED;;;;GAIG;AACH,QAAA,MAAM,WAAW;cAC2D,cAAc;2BAC9C,GAAG,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,WAE7D,GAAG,OAAO,GAAG,QAoBlB,CAAA;AAET,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,CAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Button } from '@builderbot/bot/dist/types';
|
|
2
|
+
export interface ITwilioProviderOptions {
|
|
3
|
+
accountSid: string;
|
|
4
|
+
authToken: string;
|
|
5
|
+
vendorNumber: string;
|
|
6
|
+
publicUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IMessageOptions {
|
|
9
|
+
buttons?: Button[];
|
|
10
|
+
media?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface TwilioRequestBody {
|
|
13
|
+
From: string;
|
|
14
|
+
To: string;
|
|
15
|
+
Body: string;
|
|
16
|
+
NumMedia: string;
|
|
17
|
+
MediaContentType0?: string;
|
|
18
|
+
MediaUrl0?: string;
|
|
19
|
+
Latitude?: string;
|
|
20
|
+
Longitude?: string;
|
|
21
|
+
ProfileName?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface TwilioPayload {
|
|
24
|
+
from: string;
|
|
25
|
+
to: string;
|
|
26
|
+
body: string;
|
|
27
|
+
name: string;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAEnD,MAAM,WAAW,sBAAsB;IACnC,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,eAAe;IAC5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACf"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,WAAW,WAAY,MAAM,KAAG,MAErC,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@builderbot/provider-twilio",
|
|
3
|
+
"version": "0.1.3-alpha.22",
|
|
4
|
+
"description": "> TODO: description",
|
|
5
|
+
"author": "Leifer Mendez <leifer33@gmail.com>",
|
|
6
|
+
"homepage": "https://github.com/codigoencasa/bot-whatsapp#readme",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"main": "dist/index.cjs",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"files": [
|
|
12
|
+
"./dist/"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/codigoencasa/bot-whatsapp.git"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "rimraf dist && rollup --config",
|
|
20
|
+
"test": " npx uvu -r tsm ./__tests__ ",
|
|
21
|
+
"test:coverage": "npx c8 npm run test"
|
|
22
|
+
},
|
|
23
|
+
"directories": {
|
|
24
|
+
"lib": "dist",
|
|
25
|
+
"test": "__tests__"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/codigoencasa/bot-whatsapp/issues"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@builderbot/bot": "^0.1.3-alpha.22",
|
|
32
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
33
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
34
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
35
|
+
"@types/body-parser": "^1.19.5",
|
|
36
|
+
"@types/fluent-ffmpeg": "^2.1.24",
|
|
37
|
+
"@types/follow-redirects": "^1.14.4",
|
|
38
|
+
"@types/mime-types": "^2.1.4",
|
|
39
|
+
"@types/node": "^20.11.0",
|
|
40
|
+
"@types/polka": "^0.5.7",
|
|
41
|
+
"@types/proxyquire": "^1.3.31",
|
|
42
|
+
"@types/sinon": "^17.0.3",
|
|
43
|
+
"proxyquire": "^2.1.3",
|
|
44
|
+
"rimraf": "^5.0.5",
|
|
45
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
46
|
+
"sinon": "^17.0.1"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"body-parser": "^1.20.2",
|
|
50
|
+
"fluent-ffmpeg": "^2.1.2",
|
|
51
|
+
"mime-types": "^2.1.35",
|
|
52
|
+
"polka": "^0.5.2",
|
|
53
|
+
"twilio": "4.20.0"
|
|
54
|
+
},
|
|
55
|
+
"gitHead": "e52a9fe13d30d65b650a54b6e116953c949b1158"
|
|
56
|
+
}
|