Skip to content

Instantly share code, notes, and snippets.

@RockyMtnMarc
RockyMtnMarc / Transfer_To_Agent.csv
Last active August 5, 2019 21:10
Transfer To Agent utterance dataset for Einstein Bots
MlDomainName MlIntentName Utterance
My_First_Intent_Set Transfer_To_Agent A human could do a better job here
My_First_Intent_Set Transfer_To_Agent a real person to chat with
My_First_Intent_Set Transfer_To_Agent Agent
My_First_Intent_Set Transfer_To_Agent Agent damn it
My_First_Intent_Set Transfer_To_Agent Agent now please!
My_First_Intent_Set Transfer_To_Agent Agent please!
My_First_Intent_Set Transfer_To_Agent Agent quick!
My_First_Intent_Set Transfer_To_Agent Are you a bot? I'd like a human
My_First_Intent_Set Transfer_To_Agent Ask agent
@RockyMtnMarc
RockyMtnMarc / Appointment_Related.csv
Last active August 5, 2019 22:53
Appointment utterance dataset for Einstein Bots
@RockyMtnMarc
RockyMtnMarc / Transfer_and_Appointment_Utterances.csv
Created August 5, 2019 22:57
Example utterance dataset for Einstein Bots
MlDomainName MlIntentName Utterance
My_First_Intent_Set Appointment_Related Book appointment
My_First_Intent_Set Appointment_Related Book me
My_First_Intent_Set Appointment_Related Book technician
My_First_Intent_Set Appointment_Related Book time
My_First_Intent_Set Appointment_Related Book time slot
My_First_Intent_Set Appointment_Related bring my for checkup
My_First_Intent_Set Appointment_Related bring my in for regular maintenance
My_First_Intent_Set Appointment_Related bring my in for service
My_First_Intent_Set Appointment_Related broke down
@RockyMtnMarc
RockyMtnMarc / LiveChatTranscript_CreateSurveyInvitation.apxt
Last active November 10, 2021 11:04
Apex Trigger to create a new SurveyInvitation for every new LiveChatTranscript
//This trigger creates a new SurveyInvitaion record for each LiveChatTranscript for use in a post-chat survey
//This trigger assumes that a Contact record has been associated with each LiveChatTranscript, for example using a pre-chat form
trigger LiveChatTranscript_CreateSurveyInvitation on LiveChatTranscript (before insert) {
for (LiveChatTranscript lct : Trigger.New){
if(lct.ContactId != null){
//Change %Consumer% in the following line to a unique keyword for the Community Name where your surveys are published
List<Community> thisCommunity = [SELECT NetworkId FROM Community WHERE Name LIKE '%Consumer%' LIMIT 1];
//Change %Hutch% in the following line to a unique keyword for the Survey you want to show your chat users
List<Survey> thisSurvey = [SELECT Id,Name FROM Survey WHERE Name LIKE '%Hutch%' LIMIT 1];
//This trigger updates the LiveChatTranscript.Survey_URL__c field with a valid SurveyInvitation URL and creates a lookup relationship from the SurveyInvitation.Chat_Transcript__c to the LiveChatTranscript
trigger LiveChatTranscript_CreateSurveyURL on LiveChatTranscript (before update) {
for (LiveChatTranscript lct : Trigger.New){
if(lct.Status == 'Waiting'){
List<SurveyInvitation> thisSurveyInvitation = [SELECT Id, UUID, Name FROM SurveyInvitation WHERE ChatKey__c = :lct.ChatKey LIMIT 1];
//Set the surveyName variable to the API name of your Survey record
lct.Survey_URL__c = 'https://sdodemo-main-166ce2cf6b6-16bd728c779.force.com/consumer/survey/runtimeApp.app?invitationId=' + thisSurveyInvitation[0].Id + '&surveyName=hutch_test&UUID=' + thisSurveyInvitation[0].UUID;
if (thisSurveyInvitation.size() > 0){
try {
thisSurveyInvitation[0].Chat_Transcript__c = lct.Id;
@RockyMtnMarc
RockyMtnMarc / SurveyRedirectController.apxc
Created August 17, 2019 04:17
Apex Class which retrieves the Survey_URL__c field from the LiveChatTranscript with the specified ChatKey
public class SurveyRedirectController {
public PageReference redirectToSurvey() {
String url = [SELECT Id, Survey_URL__c, ChatKey FROM LiveChatTranscript WHERE ChatKey = : ApexPages.currentPage().getParameters().get('chatKey')].Survey_URL__c;
PageReference surveyURL = new PageReference(url);
return surveyURL;
}
}
@RockyMtnMarc
RockyMtnMarc / SurveyRedirectPage.vfp
Created August 17, 2019 04:22
Visualforce Page which redirects the user to the Survey URL.
<apex:page controller="SurveyRedirectController" action="{!redirectToSurvey}" >
</apex:page>
@RockyMtnMarc
RockyMtnMarc / themeLayoutNoHeader.cmp
Created August 17, 2019 04:56
Custom Community Theme Layout for post-chat surveys with no header
<aura:component implements="forceCommunity:themeLayout" access="global" description="Custom Community Theme Layout for post-chat surveys with no header">
<div>
<div class="mainContentArea">
{!v.body}
</div>
</div>
</aura:component>
@RockyMtnMarc
RockyMtnMarc / themeLayoutNoHeader.css
Created August 17, 2019 04:59
Custom Community Theme Layout style sheet for post-chat surveys with no header
.THIS {
position: relative;
z-index: 1;
}
.THIS .surveyRuntimeSurvey.surveyScreen {
min-width: 0;
margin: -13px;
width: calc(100% + 25px) !important;
padding-bottom: 50px !important;
@RockyMtnMarc
RockyMtnMarc / SurveyInvitationURLFormula
Last active September 21, 2019 17:25
Salesforce Process Builder Formula for generating a Survey Invitation URL
'https://YOUR_DOMAIN_HERE.force.com/survey/runtimeApp.app?invitationId='+
[SurveyInvitation].Id+
'&surveyName=YOUR_SURVEY_API_NAME_HERE&UUID='
+[SurveyInvitation].UUID