How to use the botbuilder-core.TurnContext function in botbuilder-core

To help you get started, we’ve selected a few botbuilder-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / botbuilder-js / libraries / botbuilder-dialogs / src / botDebugger.ts View on Github external
protected createEmulatorContext(session: ConversationReference): TurnContext {
		// Get emulators adapter
		const emulator = this.findAdapter('emulator');
		if (!emulator) {
			throw new Error(`BotDebugger: Cannot log debug activity to emulator. Adapter not found.`)
		}

		// Create request with session address
		const request = TurnContext.applyConversationReference({
			type: ActivityTypes.Event,
			name: 'debuggerSession'
		}, session);

		// Return context for session
		return new TurnContext(emulator, request);
	}
github microsoft / BotBuilder-Samples / samples / typescript_nodejs / 01.console-echo / src / consoleAdapter.ts View on Github external
rl.on('line', (line: string) => {
            // Initialize activity
            const activity: Partial = TurnContext.applyConversationReference(
                {
                    id: (this.nextId++).toString(),
                    text: line,
                    timestamp: new Date(),
                    type: ActivityTypes.Message
                },
                this.reference,
                true
            );

            // Create context and run middleware pipe
            const context: TurnContext = new TurnContext(this, activity);
            this.runMiddleware(context, logic)
                .catch((err: Error) => { this.printError(err.toString()); });
        });
github microsoft / BotBuilder-Samples / samples / typescript_nodejs / 01.console-echo / src / consoleAdapter.ts View on Github external
public continueConversation(reference: ConversationReference, logic: (context: TurnContext) => Promise): Promise {
            // Create context and run middleware pipe
            const activity: Partial = TurnContext.applyConversationReference({}, reference, true);
            const context: TurnContext = new TurnContext(this, activity);

            return this.runMiddleware(context, logic)
                       .catch((err: Error) => { this.printError(err.toString()); });
    }
github microsoft / BotBuilder-Samples / samples / javascript_es6 / 01.browser-echo / src / webChatAdapter.ts View on Github external
onReceive(activity) {
        const context = new TurnContext(this, activity);

        // Runs the middleware pipeline followed by any registered business logic.
        // If no business logic has been registered via processActivity, a default
        // value is provided as to not break the bot.
        return this.runMiddleware(context, this.logic || function() { });
    }
}
github microsoft / botbuilder-js / libraries / botbuilder / lib / consoleAdapter.js View on Github external
rl.on('line', (line) => {
            // Initialize activity
            const activity = botbuilder_core_1.TurnContext.applyConversationReference({
                type: botbuilder_core_1.ActivityTypes.Message,
                id: (this.nextId++).toString(),
                timestamp: new Date(),
                text: line
            }, this.reference, true);
            // Create context and run middleware pipe
            const context = new botbuilder_core_1.TurnContext(this, activity);
            this.runMiddleware(context, logic)
                .catch((err) => { this.printError(err.toString()); });
        });
        return function close() {
github microsoft / botbuilder-js / libraries / botbuilder / lib / consoleAdapter.js View on Github external
continueConversation(reference, logic) {
        // Create context and run middleware pipe
        const activity = botbuilder_core_1.TurnContext.applyConversationReference({}, reference, true);
        const context = new botbuilder_core_1.TurnContext(this, activity);
        return this.runMiddleware(context, logic)
            .catch((err) => { this.printError(err.toString()); });
    }
    /**
github microsoft / botbuilder-js / libraries / botbuilder / lib / botFrameworkAdapter.js View on Github external
createContext(request) {
        return new botbuilder_core_1.TurnContext(this, request);
    }
}
github microsoft / botbuilder-js / libraries / botbuilder / src / botFrameworkAdapter.ts View on Github external
protected createContext(request: Partial): TurnContext {
        return new TurnContext(this as any, request);
    }