How to use quickblox - 7 common examples

To help you get started, we’ve selected a few quickblox 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 aichaos / rivescript-js / eg / quickblox-bot / index.js View on Github external
// Retireve all group chats where bot is in occupants list.
		QB.chat.dialog.list({type: 2}, (dialogListError, dialogList) => {
			if(dialogListError){
				console.log('[QB] dialog.list is failed', JSON.stringify(dialogListError));
				process.exit(1);
			}

			// Join bot's group chats
			dialogList.items.forEach((dialog) => {
				QB.chat.muc.join(dialog.xmpp_room_jid);
			});
		});

		// Add listeners
		QB.chat.onMessageListener = qbListeners.onMessageListener;
		QB.chat.onSubscribeListener = qbListeners.onSubscribeListener;
		QB.chat.onSystemMessageListener = qbListeners.onSystemMessageListener;
	});
}
github aichaos / rivescript-js / eg / quickblox-bot / index.js View on Github external
}, (createSessionError, res) => {
	if(createSessionError) {
		console.error('[QB] createSession is failed', JSON.stringify(createSessionError));
		process.exit(1);
	}

	// Connect to Real-Time Chat
	QB.chat.connect({
		userId: CONFIG.user.id,
		password: CONFIG.user.password
	}, (chatConnectError) => {
		if (chatConnectError) {
			console.log('[QB] chat.connect is failed', JSON.stringify(chatConnectError));
			process.exit(1);
		}

		console.log('[QB] bot is up and running');

		// Retireve all group chats where bot is in occupants list.
		QB.chat.dialog.list({type: 2}, (dialogListError, dialogList) => {
			if(dialogListError){
				console.log('[QB] dialog.list is failed', JSON.stringify(dialogListError));
				process.exit(1);
			}
github aichaos / rivescript-js / eg / quickblox-bot / index.js View on Github external
// Retireve all group chats where bot is in occupants list.
		QB.chat.dialog.list({type: 2}, (dialogListError, dialogList) => {
			if(dialogListError){
				console.log('[QB] dialog.list is failed', JSON.stringify(dialogListError));
				process.exit(1);
			}

			// Join bot's group chats
			dialogList.items.forEach((dialog) => {
				QB.chat.muc.join(dialog.xmpp_room_jid);
			});
		});

		// Add listeners
		QB.chat.onMessageListener = qbListeners.onMessageListener;
		QB.chat.onSubscribeListener = qbListeners.onSubscribeListener;
		QB.chat.onSystemMessageListener = qbListeners.onSystemMessageListener;
	});
}
github aichaos / rivescript-js / eg / quickblox-bot / index.js View on Github external
QB.chat.dialog.list({type: 2}, (dialogListError, dialogList) => {
			if(dialogListError){
				console.log('[QB] dialog.list is failed', JSON.stringify(dialogListError));
				process.exit(1);
			}

			// Join bot's group chats
			dialogList.items.forEach((dialog) => {
				QB.chat.muc.join(dialog.xmpp_room_jid);
			});
		});

		// Add listeners
		QB.chat.onMessageListener = qbListeners.onMessageListener;
		QB.chat.onSubscribeListener = qbListeners.onSubscribeListener;
		QB.chat.onSystemMessageListener = qbListeners.onSystemMessageListener;
	});
}
github aichaos / rivescript-js / eg / quickblox-bot / index.js View on Github external
body: reply,
						extension: {
							save_to_history: 1
						}
					};

					QB.chat.send(userId, answer);
				})

			}
		}
	}
};

// Create QuickBlox session
QB.createSession({
	login: CONFIG.user.login,
	password: CONFIG.user.password
}, (createSessionError, res) => {
	if(createSessionError) {
		console.error('[QB] createSession is failed', JSON.stringify(createSessionError));
		process.exit(1);
	}

	// Connect to Real-Time Chat
	QB.chat.connect({
		userId: CONFIG.user.id,
		password: CONFIG.user.password
	}, (chatConnectError) => {
		if (chatConnectError) {
			console.log('[QB] chat.connect is failed', JSON.stringify(chatConnectError));
			process.exit(1);
github aichaos / rivescript-js / eg / quickblox-bot / index.js View on Github external
var riveScriptGenerator = new RiveScript();

function loadingDone(batch_num) {
	console.log(`[RiveScript] Batch #${batch_num} has finished loading!`);
	riveScriptGenerator.sortReplies();
}

function loadingError(batch_num, error) {
	console.log(`[RiveScript] Load the batch #${batch_num} is failed`, JSON.stringify(error));
}

riveScriptGenerator.loadDirectory('../brain').then(loadingDone).catch(loadingError);


// Initialise QuickBlox
QB.init(CONFIG.appId, CONFIG.authKey, CONFIG.authSecret);

var qbListeners = {
	// Contact list listener
	onSubscribeListener: function onSubscribeListener(userId) {
		console.log(`[QB] onSubscribeListener. Subscribe from ${userId}`);

		QB.chat.roster.confirm(userId, function() {
			console.log(`[QB] Confirm subscription from user ${userId}`);
		});
	},

	// System messages listener
	onSystemMessageListener: function onSystemMessageListener(msg) {
		if(msg.extension.notification_type === '1'){
			console.log(`[QB] The user ${msg.userId} adds you to dialog`);
github aichaos / rivescript-js / eg / quickblox-bot / index.js View on Github external
onSubscribeListener: function onSubscribeListener(userId) {
		console.log(`[QB] onSubscribeListener. Subscribe from ${userId}`);

		QB.chat.roster.confirm(userId, function() {
			console.log(`[QB] Confirm subscription from user ${userId}`);
		});
	},

quickblox

QuickBlox JavaScript SDK

(Apache-2.0)
Latest version published 3 months ago

Package Health Score

68 / 100
Full package analysis