How to use the botframework-connector.ConnectorClient function in botframework-connector

To help you get started, we’ve selected a few botframework-connector 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 / samples / redux-bot-es6 / app.js View on Github external
store.subscribe(() => {
    const state = store.getState();
    if (state) {
        const last = state[state.length - 1];
        if (last && last.bot) {
            const activity = last.bot;

            const client = new ConnectorClient(credentials, activity.serviceUrl);

            if (last.replyToId) {
                // in this case we know this was a reply to an inbound activity
                client.conversations.replyToActivity(activity.conversation.id, last.replyToId, activity)
                .then(() => {
                    console.log('reply send with id: ' + last.replyToId);
                });
            }
            else {
                // otherwise just send the activity to teh conversation
                client.conversations.sendToConversation(activity.conversation.id, activity)
                    .then(() => {
                        console.log('sent activity to conversation');
                    });
            }
        }
github microsoft / botbuilder-js / samples / echobot-connector-es6 / app.js View on Github external
JwtTokenValidation.assertValidActivity(activity, req.headers.authorization, authenticator).then(() => {

        // On message activity, reply with the same text
        if (activity.type ===  ActivityTypes.Message) {
            var reply = createReply(activity, `You said: ${activity.text}`);
            const client = new ConnectorClient(credentials, activity.serviceUrl);
            client.conversations.replyToActivity(activity.conversation.id, activity.id, reply)
                .then((reply) => {
                    console.log('reply send with id: ' + reply.id);
                });
        }

        res.send(202);
    }).catch(err => {
        console.log('Could not authenticate request:', err);
github microsoft / botbuilder-js / libraries / botbuilder / src / botFrameworkAdapter.ts View on Github external
// Check if we have a streaming server. Otherwise, requesting a connector client
            // for a non-existent streaming connection results in an error
            if (!this.streamingServer) {
                throw new Error(`Cannot create streaming connector client for serviceUrl ${serviceUrl} without a streaming connection. Call 'useWebSocket' or 'useNamedPipe' to start a streaming connection.`)
            }

            return new ConnectorClient(
                credentials,
                {
                    baseUri: serviceUrl,
                    userAgent: USER_AGENT,
                    httpClient: new StreamingHttpClient(this.streamingServer)
                });
        }

        return new ConnectorClient(credentials, { baseUri: serviceUrl, userAgent: USER_AGENT });
    }
github microsoft / botbuilder-js / libraries / botframework-streaming-extensions / src / Integration / BotFrameworkStreamingAdapter.ts View on Github external
public createConnectorClient(serviceUrl: string): ConnectorClient {
        return new ConnectorClient(
            this.credentials,
            {
                baseUri: serviceUrl,
                userAgent: super['USER_AGENT'],
                httpClient: new StreamingHttpClient(this.server)
            });
    }
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / src / botDebugger.ts View on Github external
private async verifyEmulatorConversation(id: string): Promise {
		const client = new ConnectorClient(new EmulatorServiceCredentials() as any, {baseUri: process.env.EMULATOR_URL});
		try {
			const result = await client.conversations.getConversations();
			return !!result.conversations.find(conversation => conversation.id === id);
		} catch(e) {
			return false;
		}
	}
}
github microsoft / botbuilder-js / libraries / botbuilder / lib / botFrameworkAdapter.js View on Github external
createConnectorClient(serviceUrl) {
        const client = new botframework_connector_1.ConnectorClient(this.credentials, serviceUrl);
        client.addUserAgentInfo(USER_AGENT);
        return client;
    }
    /**
github microsoft / botbuilder-js / libraries / botbuilder-services / lib / botFrameworkAdapter.js View on Github external
function createClient(serviceUrl) {
                if (serviceUrl) {
                    if (!clientCache.hasOwnProperty(serviceUrl)) {
                        clientCache[serviceUrl] = new botframework_connector_1.ConnectorClient(credentials, serviceUrl);
                    }
                    return clientCache[serviceUrl];
                }
            }
            const responses = [];
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / src / botDebugger.ts View on Github external
private static async connectToEmulator(context: TurnContext): Promise {
		const client = new ConnectorClient(new EmulatorServiceCredentials() as any, {baseUri: process.env.EMULATOR_URL});
		const payload: ConversationParameters = {
			bot: context.activity.recipient,
			isGroup: context.activity.conversation.isGroup,
			members: [context.activity.recipient],
			activity: BotDebugger.trace(context.activity.conversation, 'https://www.botframework.com/schemas/debug', 'Debug', 'Debug Connection Request') as Activity,
			channelData: null
		};
		try {
			const result = await client.conversations.createConversation(payload);
			if (result._response.status === 200) {
				return result.id;
			}
		} catch (e) {
			throw e;
		}
	}
github howdyai / botkit / packages / botkit / src / adapter.ts View on Github external
public createConnectorClient(serviceUrl: string): ConnectorClient {
        const client: ConnectorClient = new ConnectorClient(this.credentials, { baseUri: serviceUrl, userAgent: USER_AGENT });
        return client;
    }