How to use the botbuilder-core.ActivityTypes.Event 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-js / libraries / botbuilder / src / skills / skillHandler.ts View on Github external
const adapter: BotFrameworkAdapter = (context.adapter as BotFrameworkAdapter);
            // Cache the ClaimsIdentity and ConnectorClient on the context so that it's available inside of the bot's logic.
            context.turnState.set(adapter.BotIdentityKey, claimsIdentity);
            context.turnState.set(this.SkillConversationReferenceKey, skillConversationReference);
            activity = TurnContext.applyConversationReference(activity, conversationReference) as Activity;
            const client = adapter.createConnectorClient(activity.serviceUrl);
            context.turnState.set(adapter.ConnectorClientKey, client);

            context.activity.id = replyToActivityId;
            switch (activity.type) {
                case ActivityTypes.EndOfConversation:
                    await this.conversationIdFactory.deleteConversationReference(conversationId);
                    SkillHandler.applyEoCToTurnContextActivity(context, activity);
                    await this.bot.run(context);
                    break;
                case ActivityTypes.Event:
                    SkillHandler.applyEventToTurnContextActivity(context, activity);
                    await this.bot.run(context);
                    break;
                default:
                    await context.sendActivity(activity);
                    break;
            }
        };
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / src / botDebugger.ts View on Github external
protected async onTurn(context: TurnContext, next: () => Promise): Promise {
		const {channelId, type, name, value} = context.activity;

		// Check for debugging mode
		const log: Partial[] = [];
		const debugging = channelId === 'emulator' || await this.inDebugSession(context);
		if (debugging) {
			// Check for debug commands from emulator
			if (type === ActivityTypes.Event && name === 'debuggerCommand') {
				const command: BotDebuggerCommand = value;
				const relatesTo = command.relatesTo;
				switch (command.name) {
					case 'loadBotState':
						const state = await this.loadBotState(relatesTo);
						await context.sendActivity(BotDebugger.trace(state, 'https://www.botframework.com/schemas/botState', 'BotState', 'Bot State'));
						break;
					case 'saveBotState':
						await this.saveBotState(relatesTo, command.value as PersistedState);
						break;
				}
				return;
			}

			// Log all activities and changes
			// - We don't need to do this for the emulator as its already seeing everything
github microsoft / botbuilder-js / libraries / botbuilder-dialogs-adaptive / src / activityProperty.ts View on Github external
public get displayLabel(): string {
        if (typeof this._value === 'object') {
            switch (this._value.type) {
                case ActivityTypes.Message:
                    return this._value.text;
                case ActivityTypes.Event:
                    return `event:${this._value.name}`;
                default:
                    return this._value.type;
            }
        } else {
            return this._value || '';
        }
    }
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / src / prompts / oauthPrompt.ts View on Github external
private isTokenResponseEvent(context: TurnContext): boolean {
        const activity: Activity = context.activity;

        return activity.type === ActivityTypes.Event && activity.name === 'tokens/response';
    }
github microsoft / botbuilder-js / libraries / botbuilder-skills / src / skillHostAdapter.ts View on Github external
protected shouldHandleSentActivity(activity: Partial): boolean {
        switch (activity.type) {
            case ActivityTypes.EndOfConversation:
            case ActivityTypes.Event:
                return true;
            default:
                return false;
        }
    }