Giter Site home page Giter Site logo

cashbot-node's Introduction

cashbot.ai: nodejs

Build Status

This library contains nodejs bindings for the cashbot.ai APIs. Each method in the library is compatible with callbacks or Promises. Note: this is a server side library and not intended for use from the client side.

cashbot.ai is a monetization platform for conversational experiences. For more information, please visit (https://cashbot.ai) or e-mail us at [email protected].

API Keys

You will need an API key to access the cashbot.ai APIs. You can request a key by either signing up (https://cashbot.ai/register) or e-mailing us at [email protected].

Installation

npm install --save cashbot

Quick Start: Facebook Messenger

// load the cashbot.ai library
// -------------------------
var Cashbot = require('cashbot');

// initialize the cashbot client
// -------------------------
var cashbot = Cashbot.init('API_KEY');

// optionally print debug messages, leave debug: false if you do not want debug messages
// -------------------------
cashbot.setConfig({ debug: true });


// send cashbot.ai user demographic information to be used to personalize recommendations
// get a Facebook carousel with personalized recommendations for the user
// returns via callback function

// IT IS CRITICAL YOU REPLACE USER.ATTRIBUTE WITH YOUR USER'S INFORMATION
// USER.ID SHOULD BE THE UNIQUE PAGE SCOPED USER ID
// -------------------------
cashbot.postGetQuery(USER.ID, { timezone: USER.TIMEZONE, gender: USER.GENDER, locale: USER.LOCALE, first_name: USER.FIRST_NAME, last_name: USER.LAST_NAME, profile_pic: USER.PROFILE_PIC, n: 3, type: 'carousel', label: 'Take a Look' }, function(err, res) {
  console.log('err: ', err);
  // returns a formatted message body
  console.log('res: ', res);
});


// send cashbot.ai user demographic information to be used to personalize recommendations
// get a Facebook list with personalized recommendations for the user
// returns via promises

// IT IS CRITICAL YOU REPLACE USER.ATTRIBUTE WITH YOUR USER'S INFORMATION
// USER.ID SHOULD BE THE UNIQUE PAGE SCOPED USER ID
// -------------------------
cashbot.postGetQuery(USER.ID, { timezone: USER.TIMEZONE, gender: USER.GENDER, locale: USER.LOCALE, first_name: USER.FIRST_NAME, last_name: USER.LAST_NAME, profile_pic: USER.PROFILE_PIC, type: 'list' })
  .then(function(res) {
    // returns a formatted message body
    console.log(res);
  })
  .catch(function(err) {
    console.log(err);
  });

Quick Start: APIs

// load the cashbot.ai library
// -------------------------
var Cashbot = require('cashbot');

// initialize the cashbot client
// -------------------------
var cashbot = Cashbot.init('API_KEY');

// optionally print debug messages, leave debug: false if you do not want debug messages
// -------------------------
cashbot.setConfig({ debug: true });


// send cashbot.ai user demographic information to be used to personalize recommendations
// get n=3 personalized recommendations for the user
// returns via callback function

// IT IS CRITICAL YOU REPLACE USER.ATTRIBUTE WITH YOUR USER'S INFORMATION
// USER.ID SHOULD BE THE UNIQUE PAGE SCOPED USER ID
// -------------------------
cashbot.postGetQuery(USER.ID, { timezone: USER.TIMEZONE, gender: USER.GENDER, locale: USER.LOCALE, first_name: USER.FIRST_NAME, last_name: USER.LAST_NAME, profile_pic: USER.PROFILE_PIC, n: 3, format: 'api' }, function(err, res) {
  console.log('err: ', err);
  // returns a formatted message body
  console.log('res: ', res);
});


// send cashbot.ai user demographic information to be used to personalize recommendations
// get n=1 personalized recommendations for the user
// returns via promises

// IT IS CRITICAL YOU REPLACE USER.ATTRIBUTE WITH YOUR USER'S INFORMATION
// USER.ID SHOULD BE THE UNIQUE PAGE SCOPED USER ID
// -------------------------
cashbot.postGetQuery(USER.ID, { timezone: USER.TIMEZONE, gender: USER.GENDER, locale: USER.LOCALE, first_name: USER.FIRST_NAME, last_name: USER.LAST_NAME, profile_pic: USER.PROFILE_PIC, n: 1, format: 'api' })
  .then(function(res) {
    // returns a formatted message body
    console.log(res);
  })
  .catch(function(err) {
    console.log(err);
  });

userDemographics Object

  required
    timezone: signed integer, offset from GMT
    gender: enumerated string, [ "male", "female" ]
    locale: Facebook locale code, e.g. "en_US"
  optional
    first_name: string
    last_name: string
    profile_pic: string, URL to profile picture

Tests

These are a work in progress

npm install npm test

Contributing

Please follow the existing coding style and add unit tests for any new or changed functionality.

License

Released under the MIT license. See file called LICENSE for more details.

Attribution/Credits

Inspired by the Mixpanel nodejs library (http://mixpanel.com/) (https://github.com/mixpanel/mixpanel-node)

Copyright (c) 2014-15 Mixpanel Original Library Copyright (c) 2012-14 Carl Sverre

cashbot-node's People

Contributors

blfletcher avatar l4ns avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.