What is AI and Machine Learning??

Hey gyus how are yuo?

I think you all are able to read the above line. Few words are incorrect but still you able to read this.
That is human Intelligence. So now you have a question that’s why you are reading this topic.

What is AI or Artificial Intelligence??
In simple words give the ability of thinking and processing to a machine as we human have. We call it AI. Let’s have an example, I copied my first line and googled it. See the results, Google corrected it as our mind corrected or read.
Screen Shot 2017-08-17 at 1.08.08 AM

You can see few more example in your daily life like Siri. Say something and it will return the best results.

You can see Tesla self-drive cars. They are very cool part of AI.

That’s it. Let’s jump to next thing.

What is Machine Learning?

In the web, you will have a bunch of articles about ML (Machine Learning). They have some big words and we are very new here. So let’s start with when you born.
I born on 9th Dec 1993 and that day I didn’t know that if I touch a fire, I can burn myself. No data inside me. As I grew up, I get that and learned some other things as well.
I learned all from my experience and some from other’s experience.

You don’t need to burn yourself to know that fire can make you harm. 🙂 You can learn from others as well. So it’s all about data that we get in our daily life routine.

Now come to the machines. They are pretty much like us, they also need to be learned. So we need to provide more and more data to machines.

Let’s have a very basic example: We have few names, their age and what they like.
Screen Shot 2017-08-17 at 1.31.53 AM

So we see here a pattern:
if age is 6,7 they like Toys
if age is 17, 19 they like Bikes
if age is 65, 78 they like Yoga

So now we need to give this data to our machine. Now the machine will store this data and generate prediction model.

Now we will give input:
Name: Hardy
Age: 7

If I ask you the same, what will Hardy like? Your answer can be Toys. But if I ask you what if Hardy’s age is 8 then ?? So you may say Cycle or Toys. You are not 100% sure. Becuase you have very few data to determine.

In ML, This prediction model may give the output as Toys. But if I give the age as 8 it can be Cycle or toys. The machine also needs more data for more accuracy.

Till now, you may get an idea about Machine Learning. Now, lets go in deep with little more technical.

Screen Shot 2017-08-17 at 2.00.10 AM

Explanation of above fig:
Let’s assume we have 100 records. We are giving 70% of data to our machine as the Training data and rest of the 30% data as the test data.

Got confused what is train and test data. So let’s assume you are a student and your teacher have a book with 100 questions with answers. But he taught you 70 questions and answers.
After that, the teacher asked you rest of the 30 question and you gave the answer 80% correctly. That is your accuracy.

Same with the machine we need to check the accuracy of our ML also. Now we also have 80% accuracy with the machine. (Why 80%? , it depends on data.)

Now we give a record to our machine. So the machine will put this record in prediction model and will provide you predictions of output.

Same with you, Now teacher asked a new question and you replied the answer basis on the 70 questions and that 80% accuracy, which you got from 30 questions.

So machine learning is all about data and data.

I think, Now we are good at basic Machine Learning.

Cheers!!!

Sentiment Analysis in Salesforce – A Part of Artificial Intelligence

Screen Shot 2017-06-07 at 11.23.42 AM

v1 (1)

What is Sentiment Analysis:
Sentiment analysis is extremely useful us to gain an overview of the public opinion behind certain topics and feedbacks. Automatically classifying text by sentiment allows you to easily find out the general opinions of people in your area of interest. For example, you might want to analyze reviews of a product to help you improve the customer experience, or to find the most or least popular product.

The Obama used sentiment analysis to gauge public opinion to policy announcements and campaign messages ahead of 2012 presidential election.

How can we get this?
There is lots of tool for sentiment analysis. But I found haven on demand easy to use API.

About HavenOnDemand Sentiment Analysis API:
The Sentiment Analysis API analyzes text to return the sentiment as positive, negative, neutral, or mixed. It contains a dictionary of positive and negative words of different types and defines patterns that describe how to combine these words to form positive and negative phrases.

 

How to implement in Salesforce:

Use Case:
You can use this API as you want but in my blog, i am using an example of feedback’s mails.

The user will send an email to Salesforce and here I am saving this email to a custom object and analyzing the sentiment of that email. So support and sales person know that which email is top to pick in morning. Because a team can have tons of emails. In these mail, most negative emails are important to work on because we want the positive feedback from clients. So it is very hard to read one by one email. But from this API you can get the sentiment score and sort them by the score.

Screen Shot 2017-06-08 at 1.38.57 AM

Implementation-
A. Get API key from HavenOnDemand:
1. Go here and register yourself.
2. After registration, Go here.
3. Then click on Generate Key button. Here you will get a popup for the name of the key. Fill this and click on Continue.
4. You will see a key here. Copy this key and save it on your computer. we need this on salesforce apex code.

B. Coding Part: Download Source Code from here.
After the code deployment. Add your API key in EMailHandler Class.
Screen Shot 2017-06-08 at 12.19.28 AM

API Explanation:

We need to send request on https://api.havenondemand.com/1/api/sync/analyzesentiment/v2

It is GET call. So you need to pass 2 params in URL.
-apikey = Your API key
-text = set the text for sentiment analysis.

Read more about API here

C. Now create an Email Services:
1. Go to Setup –> Develop –> Email Services
2. Create Email Service here as below
Email Service Name = SentimentAnalysis
Apex Class = EMailHandler
Active = Checked (It should be checked to get inbound emails.)
3. After that create new Email Addresses under Email Service.

D. Add Sentiment View Page: Now add feedback VF page to your page layout. I added in lightning view at the top.

Time to run:
Open your mailbox and send an email to an above-created email address. Salesforce will create a record of Feedback object. You can see the sentiment score and sentiment in the record.

If you have any concern then please feel free to contact me.

Please send your feedback to this email address. I will share your sentiment score on my facebook and twitter page.

sentimentanalysis@2ivr6p1y22tgkbwb5z8jsznyk9v7z0ssyk21pi9yrhx3ohl5we.7f-rozfuaq.ap5.apex.salesforce.com

Cheers!!
Happy Salesforce

Salesforce Voice Search Chrome Extension Release

icon128

You must have read the article where i wrote how can we create voice search extension. It is good for dev guys.

But all are not Dev’s so i released this. Now just install it and make your words stronger than hands. 🙂

This extension provides Speech to Text functionality. Right now you can search by typing text. It’s little time-consuming.

How does it work?
You just have to click on salesforce search bar and speak here, you will be redirected to search result as salesforce providing.

After Installing the extension refresh or open new salesforce page, click on the search bar.

Then it will ask for permission. Here allow it to Use your microphone. It is just one time setup.

Install it from here

If you like this extension then please don’t forget to give your review and feedback.🙂

Speak and Cheers!!
Happy Salesforce!!

Star War Probability Progress Bar for Opportunity :)

Screen Shot 2016-07-11 at 7.49.21 PM.png

Star Wars: The SalesForce Awakens

I am here with some fun in salesforce. 🙂 You may have seen Star War movie. It is my favorite movie. In this post i will integrate Salesforce with Star Wars.( i am Kidding 🙂 ) In this article i am creating Star War’s Sword as a progress bar.

starwars-logo

Steps to create:
1. Save this image in Static Resource in salesforce. Name it as Sword.

Screen Shot 2016-07-11 at 7.24.33 PM.png

2. Go to Setup -> Develop -> Visualforce Pages
3. Create a New page here and name it StarWarProbability
4. Copy paste below code in this page and save it.

<apex:page standardController="opportunity" showHeader="false" sidebar="false" standardStylesheets="false">
<style>
    .starWar{
        border-radius: 0px 2px 2px 0px;
        display: block;
        width: 0%;
        background-color: #fff;
        height: 8px;
        width: {!opportunity.Probability}%;
        font-size:8px;
        text-align: center;
    }

    .vader{
        box-shadow:0px 0px 10px 1px #FD4275, 0 0 1px #FD4275, 0 0 1px #FD4275, 0 0 1px #FD4275, 0 0 1px #FD4275, 0 0 1px #FD4275, 0 0 1px #FD4275;
    }
    .yoda{
        box-shadow:0px 0px 10px 1px #68B37A, 0 0 1px #68B37A, 0 0 1px #68B37A, 0 0 1px #68B37A, 0 0 1px #68B37A, 0 0 1px #68B37A, 0 0 1px #68B37A;
    }
    .obi{
        box-shadow:0px 0px 10px 1px #3B8CF8, 0 0 1px #3B8CF8, 0 0 1px #3B8CF8, 0 0 1px #3B8CF8, 0 0 1px #3B8CF8, 0 0 1px #3B8CF8, 0 0 1px #3B8CF8;
    }
    .windu{
        box-shadow:0px 0px 10px 1px #AC85B4, 0 0 1px #AC85B4, 0 0 1px #AC85B4, 0 0 1px #AC85B4, 0 0 1px #AC85B4, 0 0 1px #AC85B4, 0 0 1px #AC85B4;
    }
</style>
<div>
<table style="border-spacing: 0px;width:100%;">
<tr>
<td style="width: 114px;">
                <img src="{! $Resource.Sword }"/></td>
<td>
                <span class="vader starWar" title="{!opportunity.Probability}%">{!opportunity.Probability}%</span></td>
</tr>
</table>
</div>
</apex:page>

I have added four types of Swords in css. You just need to change in line 33. Like replace vader with yoda.

5. Now Go to Setup -> Customize -> Opportunities -> Page Layouts –> Here click on layout for show sword on detail page of opportunity record.
6. Go here for Visualforce Pages. Add Blank Section on the top and add drag your page in this section.
7. Set Section Properties ( Layout = 1-Column )
Set Visualforce Page Properties ( Height (in pixels) : 50px )

8. Save setting and open any opportunity record.

Now do changes in probality and get your StarWar Sword. 🙂

Happy Salesforce 🙂

Generate QR Code for any Salesforce Object in 5 Min

What is a QR Code?
So you may have heard that QR Codes are set to become the ‘next big thing’ but thinking to yourself, what is a QR Code!? QR or Quick Response Codes are a type of two-dimensional barcode that can be read using smartphones and dedicated QR reading devices, that link directly to text, emails, websites, phone numbers and more! You may have even got to this site by scanning a QR code!

Implement in Salesforce:
You need to follow just simple steps to create QR code for an object in salesforce. So pick any object for this. I have picked Contact object.

1. Click on Setup. It is placed on Top-Right.
2. Then in Left panel, go to Customize –> Contacts –> Fields
3. Click on New button to create the new custom field.
4. Select Formula field type here.
5. Fill field name with “QR Code” and Select Formula Return Type as “Text”
6. Then paste the following code in formula area:
IMAGE(https://chart.googleapis.com/chart?chs=200×200&cht=qr&chl=https://cs87.salesforce.com/&Id ,Scan QR code to open record in mobile.)

Note: Please change single quote (marked as red) in above formula otherwise it will give error.

You can copy above code from here. If it doesn’t work.

Explanation of above code:
1. IMAGE(image_url, alternate_text [, height, width]) : Is a function to show image with giving URL.
2. https://chart.googleapis.com/chart chs=200×200&cht=qr&chl=https://cs87.salesforce.com/’& Id
2.1 https://chart.googleapis.com/chart : Is Google Chart API
2.2 chs: Height and width of QR Code
2.3 cht: Chart Type. We need to put qr for QR code
2.4 chl: QR Code will generate this text. (In our example I am putting URL of record)

Note: Please put your domain Url instead of https://cs87.salesforce.com

Now Save your formula field and open any record. You can see a QR Code on record.

Screen Shot 2016-06-04 at 8.51.10 AM

Now you can use any QR Code scanner app on mobile.
I am using Google Goggles. You can download from here:
https://play.google.com/store/apps/details?id=com.google.android.apps.unveil&hl=en

Now Open this app and scan your code. It will look like this:

Screenshot_2016-06-04-08-54-09

Click on generated link on the bottom of the screen. It will redirect to record.

Screenshot_2016-06-04-08-54-49

Happy Salesforce!!!

Convert Standard Page Messages in Lightning Design System

OverridingPageMessages

We all know about salesforce lightning design system. A very great UI for salesforce VF pages. But we have always some challenges to convert in lightning design system from salesforce classic UI. I have posted about a javascript trick before for convert standard checkbox and radio button to the lightning design system.

In this post, I will introduce a new UI trick using Jquery and CSS. We have standard page messages, so here is a challenge to convert in these messages in salesforce lighting design system.

I have made a small trick with Jquery  and CSS. You just need to copy-paste code on your page and need to call this function in document ready or after on complete of any ajax function(Action Function).

Here is demo code:
Apex Class:

public class ConvertPageMessagesController{
    public ConvertPageMessagesController(){
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Please enter Account name'));
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please enter Account number'));
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter Account phone'));
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Please enter Account site'));
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Please enter Account industry'));
    }
}

VisalForce Page:

<apex:page controller="ConvertPageMessagesController"  >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
	<link type="text/css" rel="stylesheet" href="https://www.lightningdesignsystem.com/assets/styles/slds.css"/>

<style>
.msgIcon {
    display: none!important
}
.customMessage * {
    color: #fff!important
}
.customMessage {
    margin: 5px 0!important;
    max-width: 1280px;
    opacity: 1!important;
    width: 100%;
    font-size: 12px;
    border: 0px;
    padding-left: 10px;
}
.message {
    opacity: .1
}
</style>


<script>
    $(document).ready(function(){
       overridePageMessages();    
    });
       
    function overridePageMessages(){    
        var textureEffect = '';
        //Uncomment below line for texture effect on page messages
        //textureEffect = 'slds-theme--alert-texture';
                    
        $('.warningM3').addClass('slds-notify slds-notify--toast slds-theme--warning customMessage '+textureEffect);          
        $('.confirmM3').addClass('slds-notify slds-notify--alert slds-theme--success  customMessage '+textureEffect);    
        $('.errorM3').addClass('slds-notify slds-notify--alert slds-theme--error customMessage '+textureEffect);                  
        $('.infoM3').addClass('slds-notify slds-notify--toast customMessage '+textureEffect);    
                        
        $('.errorM3').removeClass('errorM3'); 
        $('.confirmM3').removeClass('confirmM3'); 
        $('.infoM3').removeClass('infoM3');   
        $('.warningM3').removeClass('warningM3');  
    }
</script>
<apex:pagemessages/>
</apex:page>

Call overridePageMessages() on documnet ready or oncomplete of action function(AJAX). Uncomment textureEffect for texture effect on page messages.
Fewer efforts more work. Just try it.

Happy Salesforce!!!
🙂

Sforce Chromeee – A Salesforce Theme

4x2

Hi Everyone,

I have created a salesforce theme for google chrome. Now you will be with salesforce even you are working on somewhere else.

About: Theme has cool color and big salesforce logo on Apps tab and New tab.

Install it from here

Please also provide your feedback on the theme. If you like it then please share it with your salesforce peeps.

Happy Salesforce!!!