Monday, 27 February 2017

Pre-Chat form for Live Agent | Post Chat / Pre Chat Form in salesforce | Live Agent Tutorial

Pre-Chat Form in Live Agent

In live Chat this is very common to collect some information about customer like name ,email and phone number. Providing that information to agent before they connect with customer will increase the agent's productivity as they won't have to ask those questions manually. With the help of Pre-Chat Form we can collect the same information for agent prior to start the chat.

Please follow below step to setup the Pre -Chat Form in Live Agent.

Step 1) Setup the live Agent
Please check below post how to configure Live Agent

http://amitsalesforce.blogspot.com/2016/08/live-agent-implementation-setting-up.html
URL:- http://amitsalesforce.blogspot.com/2016/08/live-agent-implementation-setting-up.html
PPT :- https://www.slideshare.net/AmitChaudhary112/live-agent

Step 2) Create Pre-Chat form code.


<apex:page showHeader="false">

<!-- This script takes the endpoint URL parameter passed from the deployment page and makes it the action for the form -->
<script type='text/javascript'>
(function() {
function handlePageLoad() {
var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
document.getElementById('prechatForm').setAttribute('action',
decodeURIComponent(endpointMatcher.exec(document.location.search)[1]));
} if (window.addEventListener) {
window.addEventListener('load', handlePageLoad, false);
} else { window.attachEvent('onload', handlePageLoad, false);
}})();
</script>

<h1>Live Agent Pre-Chat Form</h1>

<!-- Form that gathers information from the chat visitor and sets the values to Live Agent Custom Details used later in the example -->
<form method='post' id='prechatForm'>
    First name: <input type='text' name='liveagent.prechat:ContactFirstName' id='firstName' /><br />
    Last name: <input type='text' name='liveagent.prechat:ContactLastName' id='lastName' /><br />
    Email: <input type='text' name='liveagent.prechat:ContactEmail' id='email' /><br />
    Phone: <input type='text' name='liveagent.prechat:ContactPhone' id='phone' /><br />
    Issue: <input type='text' name='liveagent.prechat:CaseSubject' id='subject' /><br />

<!-- Hidden fields used to set additional custom details -->
    <input type="hidden" name="liveagent.prechat:CaseStatus" value="New" /><br />
    
    <!-- This example assumes that "Chat" was added as picklist value to the Case Origin field -->
    <input type="hidden" name="liveagent.prechat:CaseOrigin" value="Chat" /><br />
    
    <!-- This example will set the Case Record Type to a specific value for the record type configured on the org. Lookup the case record type's id on your org and set it here -->
    <input type="hidden" name="liveagent.prechat:CaseRecordType" value="012D00123456789" />
    
    <!-- Used to set the visitor's name for the agent in the Console -->
    <input type="hidden" name="liveagent.prechat.name" id="prechat_field_name" />

<!-- map: Use the data from prechat form to map it to the Salesforce record's fields -->
<input type="hidden" name="liveagent.prechat.findorcreate.map:Contact" value="FirstName,ContactFirstName;LastName,ContactLastName;Email,ContactEmail;Phone,ContactPhone" />

<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Subject,CaseSubject;Status,CaseStatus;Origin,CaseOrigin;RecordTypeId,CaseRecordType" />

<!-- doFind, doCreate and isExactMatch example for a Contact: 
    Find a contact whose Email exactly matches the value provided by the customer in the form 
    If there's no match, then create a Contact record and set it's First Name, Last Name, Email, and Phone to the values provided by the customer -->
<input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Contact" value="Email,true" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Contact" value="Email,true" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Contact" value="FirstName,true;LastName,true;Email,true;Phone,true" />

<!-- doCreate example for a Case: create a case to attach to the chat, set the Case Subject to the value provided by the customer and set the case's Status and Origin fields -->
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Subject,true;Status,true;Origin,true;RecordTypeId,true" />

<!-- linkToEntity: Set the record Contact record, found/created above, as the Contact on the Case that's created --> 
<input type="hidden" name="liveagent.prechat.findorcreate.linkToEntity:Contact" value="Case,ContactId" />

<!-- showOnCreate: Open the Contact and Case records as sub-tabs to the chat for the agent in the Console -->
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Contact" value="true" />
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" />

<!-- saveToTranscript: Associates the records found / created, i.e. Contact and Case, to the Live Chat Transcript record. --> 
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Contact" value="ContactId" />
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Case" value="CaseId" />

<!-- displayToAgent: Hides the case record type from the agent -->
<input type="hidden" name="liveagent.prechat.findorcreate.displayToAgent:CaseRecordType" value="false" />

<!-- searchKnowledge: Searches knowledge article based on the text, this assumes that Knowledge is setup -->
<input type="hidden" name="liveagent.prechat.knowledgeSearch:CaseSubject" value="true" />

<input type='submit' value='Chat Now' id='prechat_submit' onclick="setName()"/>

<!-- Set the visitor's name for the agent in the Console to first and last name provided by the customer -->
<script type="text/javascript">
   function setName() {
    document.getElementById("prechat_field_name").value =  
        document.getElementById("firstName").value + " " + document.getElementById("lastName").value;
    }
</script>

<style type="text/css">
p {font-weight: bolder }
</style>

</form>
</apex:page>
Sample code :- https://developer.salesforce.com/docs/atlas.en-us.live_agent_dev.meta/live_agent_dev/live_agent_pre_chat_forms_code_sample.htm


Step 3) Configure the Pre-Chat code In Live Agent

1) Go to Setup -> Customize -> Live Agent --> Chat Button & Invitations


2) Edit Button setting and add VF page in Pre-Chat Form like below screen shot


3) Click Save




Related Link
1) https://developer.salesforce.com/docs/atlas.en-us.live_agent_dev.meta/live_agent_dev/live_agent_pre_chat_forms_code_sample.htm

2) https://developer.salesforce.com/docs/atlas.en-us.live_agent_dev.meta/live_agent_dev/live_agent_pre_chat_forms.htm


Thanks
Amit Chaudhary
@amit_sfdc 
 

Friday, 10 February 2017

Salesforce Tutorial | How to learn Test class | Test Class Best Pratice | Sample Test class | Test Factory


Apex Unit Tests

In Salesforce , the code must have 75% code coverage to be deploy in Production. This code coverage is performed by the test classes. Please check below post to learn about test classes in salesforce :-


1) Apex Testing



Please check above Trailhead module to learn more about test classes.

2) Best Practice for Test classes | Sample Test class

http://amitsalesforce.blogspot.com/2015/06/best-practice-for-test-classes-sample.html

Please check above post to see how to write test class for Trigger , Standard Controller , Controller and StandardSetController . With Test Class best practice. 


3) Test Utility Classes | TestDataFactory | Util Test in salesforce

 

http://amitsalesforce.blogspot.com/2017/01/test-utility-classes-testdatafactory.html

Test utility classes contain reusable code for test data creation. Please check above post for How to create Test Data Factory in salesforce with example.

4) Test classes with @isTest

http://amitsalesforce.blogspot.com/2015/09/test-classes-with-istest.html

Please check above post for  @isTest annotation uses and Limitation.

5) StartTest and stopTest Method

 

StartTest and StopTest are standard test methods which are available for test classes. Please check above post for StartTest and StopTest Method uses and Limitation.  


6) Salesforce Testing Best Practice Guidelines | Unit Test Mechanism in Salesforce | Test Methods

Please check above post for Unit Test Mechanism in Salesforce and for Test class Best practice.


7) Code Coverage Report in excel Format | Test Class Result in XLS
http://amitsalesforce.blogspot.com/2015/09/code-coverage-report-in-excel-format.html

Some time we need to Download/Export the code coverage for each class in excel file . So same we can use the Code Coverage Report App. Please check above post for same

 

 

8) @testSetup ( Set Up Test Data for an Entire Test Class )


Please check above post how to create test data for entire test class.

 


 

Thanks,

Amit Chaudhary

 

Monday, 6 February 2017

Salesforce Apex Hours:- Live Agent | Farmington Hills Salesforce Developer Group





Farmington Hill Salesforce Developer group organized another successful event on 4th Feb 2017, focusing on Live Agent Chat. We are happy that this time we were able to complete some knowledge base session.

First of All I would like to thank to our Farmington Hills Salesforce Developer group members for there support. Now our Farmington Hills Developer Group family is increasing and now we are more the 111+ member in same group.


Agenda :-
• Live Agent Chat .
• Trailhead badges
• Games & Swag !


Our Sponsors :-
Thank you WorkForce Software and Tom Nieman to provide the space for our meetup this time.


Facebook Page :- https://www.facebook.com/FarmingtonHillsSfdcdug/
Meetup Link :- http://www.meetup.com/Farmington-Hills-Salesforce-Developer-Meetup/ 

Twitter Tag :- #FarmingtonHillsSFDCdug
Live Agent PPT :- http://www.slideshare.net/AmitChaudhary112/live-agent

 


http://www.slideshare.net/AmitChaudhary112/live-agent



Some Pic of our Meetup
Meetup Place :- WorkForce Software | 38705 Seven Mile Road, Livonia, MI
.





Thanks,
Amit Chaudhary
@amit_sfdc



Thursday, 2 February 2017

Success Story of : - Mike Martin


Welcome to my 5th Salesforce Success Story series. This series is focused on success story and to inspire/encourage new user/Developer. And why we should join our local Salesforce Developer/User group.




1) Your Job Title

[Mike Martin ] :- I am a Client Partner with Appirio.  I am responsible for building and growing relationships with Salesforce clients in the northern midwest.

2) Your success Story   

[Mike Martin ] :- I was introduced to the Salesforce Ecosystem when I started a new job as a Sales Engineer for a software company here in Indianapolis back in 2008.  The company had been using Salesforce for 3-4 years, and had a solid implementation, but the Salesforce product owner was leaving the company, and they needed someone to take over.  I spent most of my first 6 months in the role learning about Salesforce and connecting with the local Salesforce community, which was pretty small at the time.  As many also-admins learn, Salesforce became a huge part of my day to day job function, which led me to look to the ecosystem for my career path when it was time to move on from that organization.  The rest, as they say, is history!  I left that organization to join a small salesforce consulting company, which was then acquired by Appirio.  I've been incredibly lucky to be a part of such a salesforce focused organization.  Over my 6 and a half years here, I have been able to continue my involvement in the Salesforce community by stepping into a leadership role with the Indianapolis Salesforce User Group, and have been recognized as a Salesforce MVP.


3) Why we Should Join a Salesforce User/Developer Group


[Mike Martin ] :-
1. Networking!  It's a great opportunity to meet other professionals in the same field and share ideas.
2. Learning!  Presentations are always informative, and there's always an expert on hand (or at least someone who has likely been through a similar situation or problem you may be facing!
3. Fun!  As you probably know about the Salesforce community, there are a lot of great people involved in the community, and I always look forward to User Group meetings to catch up with friends and contacts! ( Amit :- I agree Networking ,Fun and Learning )

4) Advice for new Salesforce Developer
 

[Mike Martin ] :- It’s been said, and I will say it again…the Community!  I was initially successful in the Salesforce ecosystem thanks to User Groups and Twitter, so I always encourage all new users to take advantage of resources local to them through the awesome User Group program.  Twitter, the Success Community, and of course now Trailhead are also great places to get started.

5) Trailhead badges


[Mike Martin ] :- 71 as of last count.  I'm an Expeditioner!  I hope to grab a couple more at the next Salesforce Indy User Group Trailhead Lockin, and level up to Ranger! (Amit :- All The best)


Follow Mike Martin on:
Twitter :  @mikemartin__c




 If you want to share your Salesforce Success Story, Please feel free to drop me an email :- amit.salesforce21@gmail.com






<<PREVIOUS       NEXT>>


Thanks
Amit Chaudhary
@amit_sfdc