GithubHelp home page GithubHelp logo

botkit-salesforce-bot's Introduction

botkit-salesforce-bot

Code-Style:Standard License:MIT chat-svg

botkit-salesforce-bot allows you to create conversational Salesforce apps ("bots") via RingCentral and glip API using Botkit's familiar interface.

It takes advantage of Botkit's core functionality thus allowing you to create complex conversational flows via a simple interface. It also allows you to use custom storage methods/systems to enable data persistence across sessions.

What is Botkit?

Here's an excerpt of Botkit's readme.md file:

[Botkit] provides a semantic interface to sending and receiving messages so that developers can focus on creating novel applications and experiences instead of dealing with API endpoints.

Use Case

You can use botkit-salesforce-bot to query salesforce to obtain the following information

  • Search account Acme or Search Acme in acccounts
salesforce: search account <ACCOUNT_NAME>
  • Search contact Lisa Smith or Search Lisa Smith in contacts
salesforce: search contact <CONTACT_NAME>
  • Top 5 deals (Default to 5 deals)
salesforce: top <NUMBER> deals
  • Search opportunity Big Deal
salesforce: search opportunity <OPPORTUNITY_NAME>
  • Create contact
salesforce: create contact 
  • Create case
salesforce: create case

Installation

$ npm install  

First, create a copy of env.template file and rename it to .env. Configure the properties in the file:

* `GLIP_SERVER`: Glip server (sandbox: https://platform.devtest.ringcentral.com or production: https://platform.ringcentral.com)
* `GLIP_APPKEY`: Application Key 
* `GLIP_APPSECRET`: Application Secret
* `GLIP_USERNAME`: RingCentral Username
* `GLIP_PASSWORD`: RingCentral Password
* `GLIP_EXTENSION`: RingCentral Extension
* `SF_CLIENT_ID`: Salesforce ClientID
* `SF_CLIENT_SECRET`: Salesforce ClientSecret
* `SF_USER_NAME`: Salesforce Username
* `SF_PASSWORD`: Salesforce Password

Run the command in the terminal to launch the bot.

$ npm start

Details

Note: This document assumes that you are familiarized with Botkit and RingCentral API

require('dotenv').config();

var Botkit = require('botkit'),
    os = require('os'),
    url = require('url'),
    http = require('http'),
    request = require('request'),
    formatter = require('./modules/glip-formatter'),
    salesforce = require('./modules/salesforce');


var controller = Botkit.glipbot({
    debug: false,
});

spawn() your bot instance:

var bot = controller.spawn({
    server: process.env.GLIP_SERVER,
    appKey: process.env.GLIP_APPKEY,
    appSecret: process.env.GLIP_APPSECRET,
    username: process.env.GLIP_USERNAME,
    password: process.env.GLIP_PASSWORD,
    extension: process.env.GLIP_EXTENSION,
}).startRTM();

Then you need to set up your Web server and create the webhook endpoints so your app can receive Glip messages:

controller.setupWebserver(process.env.PORT, function (err, webserver) {
  controller.createWebhookEndpoints(controller.webserver, bot, function () {
    console.log('Glip-Salesforce-bot is online!')
  })
})

And finally, you can setup listeners for specific messages, like you would in any other botkit bot:

controller.hears(['salesforce: search account (.*)', 'salesforce: search (.*) in accounts'], 'message_received', function (bot, message) {
    var name = message.match[1];
    salesforce.findAccount(name).then(function (accounts) {
        console.log(JSON.stringify(accounts));
        if(accounts && accounts.length > 0){
            var data = null;
            data = "I found these accounts matching  '" + name + "':\n\n"
            accounts.forEach(function (account) {
                data += "**Name** \n\n"
                data +=  account.get("Name") + "\n\n"
                data += "**Link**"
                data += "https://login.salesforce.com/" + account.getId() + "\n\n"
                data += "**Phone**"
                data += account.get("Phone") + "\n\n"
                data += "**Address**"
                data += account.get("BillingStreet") + ", " + account.get("BillingCity") + " " + account.get("BillingState") + "\n\n"
            })
            bot.reply(message, data);
        } else {
            bot.reply(message, "No Accounts found for " + name );
        }
    });
});

Reference

Please see botkit's guide and reference document here.

Contributing

Bug Reports & Feature Requests

Something does not work as expected or perhaps you think this module needs a feature? Please open an issue using GitHub's issue tracker. Please be as specific and straightforward as possible.

Developing

Pull Requests (PRs) are welcome. Make sure you follow the same basic stylistic conventions as the original code (i.e. "JavaScript standard code style"). Your changes must be concise and focus on solving a single problem.

License

The MIT License (MIT)

Copyright (c) 2016

botkit-salesforce-bot's People

Contributors

pkvenu avatar

Stargazers

 avatar

Watchers

 avatar  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.