UNPKG

@wearekadence/botbuilder-adapter-twilio-sms

Version:
43 lines 1.59 kB
"use strict"; /** * @module botbuilder-adapter-twilio-sms */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.TwilioBotWorker = void 0; const botkit_1 = require("@wearekadence/botkit"); /** * This is a specialized version of [Botkit's core BotWorker class](core.md#BotWorker) that includes additional methods for interacting with Twilio SMS. * It includes all functionality from the base class, as well as the extension methods below. * * When using the TwilioAdapter with Botkit, all `bot` objects passed to handler functions will include these extensions. */ class TwilioBotWorker extends botkit_1.BotWorker { /** * A copy of the Twilio API client. */ api; // Twilio api /** * Start a conversation with a given user identified by their phone number. Useful for sending pro-active messages: * * ```javascript * let bot = await controller.spawn(); * await bot.startConversationWithUser(MY_PHONE_NUMBER); * await bot.send('An important update!'); * ``` * * @param userId A phone number in the form +1XXXYYYZZZZ */ async startConversationWithUser(userId) { return this.changeContext({ channelId: 'twilio-sms', conversation: { id: userId }, bot: { id: this.controller.getConfig('twilio_number'), name: 'bot' }, user: { id: userId } }); } } exports.TwilioBotWorker = TwilioBotWorker; //# sourceMappingURL=botworker.js.map