You need to sign in to do that
Don't have an account?
Plainview
Assign Live Agent Chat Leads to Agent/User who conducted the Chat.
Assigning Live Chat Leads to Reps who handled the Chat:
For live chat leads, is there a way for the leads generated by the Live Agent Chat to be assigned to the sales rep. that picks up the chat? Currently in our org., if a rep./user picks up a chat and handles it, it gets reassigned to a Sales Manager, who then has to assign it back to them.
Thanks!
Julien
For live chat leads, is there a way for the leads generated by the Live Agent Chat to be assigned to the sales rep. that picks up the chat? Currently in our org., if a rep./user picks up a chat and handles it, it gets reassigned to a Sales Manager, who then has to assign it back to them.
Thanks!
Julien
1.) If it is through a trigger, consider changing the trigger.
2.) If it is because of the Sales Manager being a default lead owner or something, consider adding a trigger on the Live Chat Transcript object.
Thanks for your response. We currently have only two Live Agent Triggers, as follows. Can you see anything in these that could be revised?
trigger LiveChatTranscriptUpdateLead on LiveChatTranscript (before insert, before update) {
//build a map where the key is the LeadId and the value is the new ownerID
Map<Id, Id> leadOwnerMap = new Map<Id, Id>();
for (LiveChatTranscript ts : Trigger.new) {
if (ts.LeadId != null) {
leadOwnerMap.put(ts.LeadId, ts.OwnerId);
}
}
if (!LeadOwnerMap.isEmpty()) {
LeadUpdateOwnerChat.updateLeadOwner(leadOwnerMap);
}
}
And ...
trigger LiveChatTranscriptUpdateContactAndCase on LiveChatTranscript (before insert, before update) {
//build 2 maps
//they both have the LiveChatTranscript ID as the key
//one has the value of any Case ID, and the other has the value of any Contact Id
Map<Id, Id> transcriptCaseMap = new Map<Id, Id>();
Map<Id, Id> transcriptContactMap = new Map<Id, Id>();
for (LiveChatTranscript ts : Trigger.new) {
if (ts.CaseId != null) {
transcriptCaseMap.put(ts.Id, ts.CaseId);
}
if (ts.ContactId != null) {
transcriptContactMap.put(ts.Id, ts.ContactId);
}
}
if ( (!transcriptCaseMap.isEmpty()) || (!transcriptContactMap.isEmpty()) ) {
//doSomething(transcriptCaseMap, transcriptContactMap);
}
The first Trigger updates the Lead owner, but the major chunk of the code lies in the "LeadUpdateOwnerChat" apex class which is being called by the trigger. We should look at that class code as well to understand.
public class LeadUpdateOwnerChat {
static final Id SALES_SITE_GUEST_USER = '00500000007CVPw';
@future
public static void updateLeadOwner(Map<Id, Id> leadOwnerMap) {
//map coming has the key as the lead id and the value as the new owner id
//Id saleSiteGuestUser = '00500000007CVPw'; //leads created by the chat will have this owner
//build a list of the Leads we need to change the owner on
if (!leadOwnerMap.isEmpty()) {
List<Lead> leadList = new List<Lead>();
leadList = [SELECT Id, OwnerId FROM Lead WHERE Id IN: leadOwnerMap.keySet() AND OwnerId=: SALES_SITE_GUEST_USER];
if (!leadList.isEmpty()) {
for (Lead l : leadList) {
l.OwnerId = leadOwnerMap.get(l.Id);
}
updateEmailPrefsAsync.inFutureContext = true;
update leadList;
}
}
}
static testMethod void doTest() {
//create a test Lead
Lead testLead = new Lead(OwnerId = SALES_SITE_GUEST_USER,
FirstName = 'John',
LastName = 'Smith',
Email = 'test@test.com',
LeadSource = 'Corporate Website, Live Chat',
Company = 'ACME');
insert testLead;
update testLead;
//create a test sales rep
Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
User u = new User(Alias = 'test4a6', Email='standarduser@testorg.com',
EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles', UserName='test4a6@test4a6.com');
insert u;
update u;
Map<Id, Id> leadOwnerMap = new Map<Id, Id>();
leadOwnerMap.put(testLead.Id, u.Id);
Test.startTest();
updateLeadOwner(leadOwnerMap);
Test.stopTest();
}
}
I've been instructed by Salesforce support to add some logic to the code that says, "If Lead comes from Live Agent Chat, update the check box to true, record is retained to the Chat rep."
I have created a custom checkbox field on the Lead Object (Live Agent Lead) and am wondering what the logic would look like and where to insert it in the code.
So far, I have:
if (!LiveAgentLead.isEmpty()) {
LeadUpdateLiveAgent.updateLiveAgentLead = true;
}
... but am having difficulty fleshing it out and placing it.
Any guidance is greatly appreciated.
Thanks,
Julien