All Projects → google → chatbase-node

google / chatbase-node

Licence: Apache-2.0 license
Quickly integrate your Node.js chatbot with Chatbase Analytics

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to chatbase-node

piw5 bot warfare
The Bot Warfare mod for PlutoniumIW5
Stars: ✭ 57 (-22.97%)
Mutual labels:  bots
FunUtils
Some codes i wrote to help me with me with my daily errands ;)
Stars: ✭ 43 (-41.89%)
Mutual labels:  bots
Slack-logger-bot
Simple slack bot that can save all of your team messages on your server so that you can still read them even if you exceeds the 10,000 messages in the archive.
Stars: ✭ 47 (-36.49%)
Mutual labels:  bots
rtelegram
Control rTorrent via a Telegram bot
Stars: ✭ 39 (-47.3%)
Mutual labels:  bots
vcodes
It is a Discord-based, open-source website. Titles it contains; code sharing, server list, Bot list, uptime system.
Stars: ✭ 151 (+104.05%)
Mutual labels:  bots
exocortex-halo
Various and sundry additional pieces of software I've written to incorporate into my exocortex.
Stars: ✭ 65 (-12.16%)
Mutual labels:  bots
games-wabot
Games-wabot is RPG Bot Whatsapp. Now support Multi-device!!, check branch multi-device
Stars: ✭ 165 (+122.97%)
Mutual labels:  bots
nlp-dialogue
A full-process dialogue system that can be deployed online
Stars: ✭ 69 (-6.76%)
Mutual labels:  bots
telegram bitcoin bot
Telegram Auto Mining Bitcoins In Termux
Stars: ✭ 115 (+55.41%)
Mutual labels:  bots
zulipbot
GitHub workflow-optimizing bot by @zulip
Stars: ✭ 70 (-5.41%)
Mutual labels:  bots
spanky.py
Chat-bot overlay framework that can run on top of any python-based bot and call plugins on various events
Stars: ✭ 14 (-81.08%)
Mutual labels:  bots
Hutoma-Conversational-AI-Platform
Hu:toma AI is an open source stack designed to help you create compelling conversational interfaces with little effort and above industry accuracy
Stars: ✭ 35 (-52.7%)
Mutual labels:  bots
Viber-and-the-Microsoft-Bot-Framework
se02035.github.io/viber-and-the-microsoft-bot-framework/
Stars: ✭ 16 (-78.38%)
Mutual labels:  bots
airy
💬 Open source conversational platform to power conversations with an open source Live Chat, Messengers like Facebook Messenger, WhatsApp and more - 💎 UI from Inbox to dashboards - 🤖 Integrations to Conversational AI / NLP tools and standard enterprise software - ⚡ APIs, WebSocket, Webhook - 🔧 Create any conversational experience
Stars: ✭ 299 (+304.05%)
Mutual labels:  bots
BooksAndBot
Telegram inline bot. Search for books and share them in a conversation
Stars: ✭ 26 (-64.86%)
Mutual labels:  bots
awesome-botframework
🤖 A curated list of awesome Microsoft Bot Framework related things
Stars: ✭ 30 (-59.46%)
Mutual labels:  bots
twitter-crypto-bot
This is a Twitter bot that tweets about cryptocurrencies prices every certain amount of minutes
Stars: ✭ 21 (-71.62%)
Mutual labels:  bots
Idle-RPG-Bot
An Idle-RPG bot for Discord
Stars: ✭ 47 (-36.49%)
Mutual labels:  bots
up 1 ao 99 todas classes-bro
Esta macro pretende upar do nível 1 de base até o 99 de todas as classes do ragnarok no servidor Brasileiro
Stars: ✭ 26 (-64.86%)
Mutual labels:  bots
YukkiMusicBot
Telegram Group Calls Streaming bot with some useful features, written in Python with Pyrogram and Py-Tgcalls. Supporting platforms like Youtube, Spotify, Resso, AppleMusic, Soundcloud and M3u8 Links.
Stars: ✭ 860 (+1062.16%)
Mutual labels:  bots

Chatbase Node.JS Client

This is not an official Google Product

Use

Install Via NPM

npm install --save @google/chatbase

Require the client in the target application:

var chatbase = require('@google/chatbase');

Set a valid api key, user id, agent-type, and platform on the imported module to automatically create new messages with these fields pre-populated:

var chatbase = require('@google/chatbase')
	.setApiKey(process.env.MY_CHATBASE_KEY) // Your Chatbase API Key
	.setPlatform('PLATFORM-X') // The platform you are interacting with the user over
	.setAsTypeUser(); // The type of message you are sending to chatbase: user (user) or agent (bot)
	
var msg = chatbase.newMessage();
// the following would then be true
assert(msg.api_key === process.env.MY_CHATBASE_KEY);

Or one can set these on each individual message. Note: api key and user id must be provided as arguments to newMessage if one would like to override the factory when it has been previously set.

var chatbase = require('@google/chatbase')
	.setAsTypeAgent()
	.setPlatform('PLATFORM-Y');
	
var msg = chatbase.newMessage('my-api-key', 'my-user-id')
	.setAsTypeUser()
	.setPlatform('PLATFORM-Y');
// the following would then be true
assert(msg.platform === 'PLATFORM-Y');

All fields, with the exception of user id and api key can be set on a message instance. User id and api key must be given as arguments when the message is instantiated.

var chatbase = require('@google/chatbase');
	
var msg = chatbase.newMessage('my-api-key', 'my-user-id')
	.setAsTypeUser() // sets the message as type user
	.setAsTypeAgent() // sets the message as type agent
	// WARNING: setTimestamp() should only be called with a Unix Epoch with MS precision
	.setTimestamp(Date.now().toString()) // Only unix epochs with Millisecond precision
	.setPlatform('PLATFORM-Z') // sets the platform to the given value
	.setMessage('MY MESSAGE') // the message sent by either user or agent
	.setIntent('book-flight') // the intent of the sent message (does not have to be set for agent messages)
	.setAsHandled() // set the message as handled -- this means the bot understood the message sent by the user
	.setAsNotHandled() // set the message as not handled -- this means the opposite of the preceding
	.setVersion('1.0') // the version that the deployed bot is
	.setUserId('user-1234') // a unique string identifying the user which the bot is interacting with
	.setAsFeedback() // sets the message as feedback from the user
	.setAsNotFeedback() // sets the message as a regular message -- this is the default
	.setCustomSessionId('123') // custom sessionId. A unique string used to define the scope of each individual interaction with bot.
	.setMessageId('123'); // the id of the message, this is optional
	.setClientTimeout(5000) // Set the TTL in Milliseconds on requests to the Chatbase API. Default is 5000ms.

Once a message is populated, one can send it to the service and listen on its progress using promises. Note that timestamp is not explicitly set here (although it can be) since it is automatically set on the message to the time of instantiation. Note also that the client type does not need to be explictly set either unless an agent client type is required since the message will automatically default to the user type.

var chatbase = require('@google/chatbase');

chatbase.newMessage('my-api-key')
	.setPlatform('INTERWEBZ')
	.setMessage('CAN I HAZ?')
	.setVersion('1.0')
	.setUserId('unique-user-0')
	.send()
	.then(msg => console.log(msg.getCreateResponse()))
	.catch(err => console.error(err));

Given that a newly created message can be updated this can be achieved via the message interface as well.

var chatbase = require('@google/chatbase');

chatbase.newMessage('my-api-key', 'my-user-id')
	.setPlatform('INTERWEBZ')
	.setMessage('DO NOT WORK')
	.setVersion('1.0');
	.setUserId('unique-user-0')
	.send()
	.then(msg => {
		msg.setIntent('an-intent')
			.setAsFeedback()
			.setAsNotHandled()
			.update()
			.then(msg => console.log(msg.getUpdateResponse()))
			.catch(err => console.error(err));
	})
	.catch(err => console.error(err));

Groups of messages can also be queued and sent together:

var chatbase = require('@google/chatbase');

const set = chatbase.newMessageSet()
	// The following are optional setters which will produce new messages with
	// the corresponding fields already set!
	.setApiKey('abc')
	.setPlatform('chat-space');

// Once can add new messages to the set without storing them locally
set.newMessage()
	.setMessage('test_1')
	.setIntent('book-flight')
	.setUserId('unique-user-0')
	.setClientTimeout(8000)
	// This is a regular message object with all the same setter with the caveat
	// that one cannot send the message individually. All other setter methods
	// still apply though.

// One can also store the reference to the individual message if one would like
// to keep a reference to the individual message instance
const msg = set.newMessage()
	.setMessage('test_2')
	// Pass msg around and profit

// Once the desired messages are queued on the set it can be sent
set.sendMessageSet()
	.then(set => {
		// The API accepted our request!
		console.log(set.getCreateResponse());
	})
	.catch(error => {
		// Something went wrong!
		console.error(error);
	})
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].