1. Home
  2. Docs
  3. Service Cloud
  4. Chatbots
Log a Case

Service Cloud Einstein Chatbots

Use Zenkraft's Chatbot integration to answer WISMO and process returns automatically.

Install Multi-Carrier

To install, begin by going to the Salesforce AppExchange and finding the Multi-carrier for Salesforce listing. You can find the app through Search or by clicking this link.

Click on the Get It Now button and select the desired destination (sandbox or production). Multi-carrier for Salesforce can be installed in both Sandbox (does not expire) and Production (7 day trial) instantly. Click Continue.

Preference Setup

If you want to test the shipping functionality then we recommend using our test FedEx preference (this is because FedEx offers the most friendly test environment). By using this test preference you won't be charged for any of your test shipments.

You can add this by going to Zenkraft Settings and turning on Demo Mode and then clicking the "Create FedEx Test Preference" button.

Otherwise please do go ahead and add your own preferences. Make sure Demo mode is off though, otherwise you might see some authentication errors.

Set up the Bot

The first step is to make sure you are in Lightning Experience. You can then click on Setup. In the quickfind box search for "bot", you should then see the below link you can click on.

Click on the New bot link and you will then be able to configure your bot as your business processes require.

Here is an example screenshot of how you can set up your bot to get the latest order status, to create a return label and to change the delivery date.

The communication between the bot and our app is a simple bit of apex code that can be added and modified to suit your business needs.

You can find them below for tracking and creating a return

Tracking


        public with sharing class BotTrackOrder {

            @InvocableMethod(label='Bot Track Shipment')
            public static List trackShipment(Request[] requests) {
        
                List resp = new List();
        
                Response r = new Response();
        
                try {
                    String email_address = requests[0].orderEmail;
                    
                    List orders = [SELECT Id, Name, OrderNumber FROM Order WHERE Order_Email__c =:email_address OR OrderNumber =: email_address LIMIT 1];
        
                    String order_name = orders[0].OrderNumber;
                    r.orderId = order_name;
                    
                    Id orderId = orders[0].Id;
                    
                    List shipments = [
                        SELECT 
                            zkmulti__Tracking_Number__c,
                            zkmulti__Status_Description__c,
                            zkmulti__Shipmate_Preference__c
                        FROM zkmulti__MCShipment__c
                        WHERE Order__c =: orderId
                        LIMIT 1
                    ];
        
                    zkmulti__MCShipment__c shipment = shipments[0];
        
                    Map createShipmentParameter = new Map();
                    createShipmentParameter.put('trackingNumber', shipment.zkmulti__Tracking_Number__c);
                    createShipmentParameter.put('encryptedKey', 'D3dr0Jr4sjVCeZzhzlX2eYOKXSFu1qsEpoNhDwB/KOtPtCLBY7FXkbHx6efEtvm7');
                    createShipmentParameter.put('userId', '0050b000004O0fI');
        
                    shipment = [
                        SELECT 
                            zkmulti__Tracking_Number__c, zkmulti__Carrier__c,
                            zkmulti__Status_Description__c, zkmulti__Delivery_Date__c, zkmulti__Actual_Delivery_Date__c,
                            zkmulti__Shipmate_Preference__c
                        FROM zkmulti__MCShipment__c
                        WHERE Id =: shipment.Id
                        LIMIT 1
                    ];            
                    
                    DateTime dt = shipment.zkmulti__Actual_Delivery_Date__c;
                    String formatted = dt.formatGMT('EEE, MMM d yyyy');
        
                    r.shipmentStatus = ':\n\nCarrier: ' + shipment.zkmulti__Carrier__c 
                        + ' \n\nStatus: ' +  shipment.zkmulti__Status_Description__c
                        + ' \n\nDelivery Date:\n' + formatted;
                }
                catch (Exception e) {
                    r.shipmentStatus = e.getMessage();
                }
        
                resp.add(r);
                return resp;
            }
        
            public with sharing class Request {
                @InvocableVariable(label='orderEmail' required=true)
                public String orderEmail;
            }
        
            public with sharing class Response {
                @InvocableVariable(label='shipmentStatus' required=true)
                public String shipmentStatus;
        
                @InvocableVariable(label='orderId' required=true)
                public String orderId;
            }
        
        
        }

    

Create a Return Label


        public without sharing class BotReturnOrder {

            @InvocableMethod(label='Bot Return Order')
            public static List returnOrder(Request[] requests) {
                List resp = new List();
                String orderNumber = requests[0].orderNumber;
        
                Response r = new Response();
                try {
                    List orders = [SELECT Id, Name, OrderNumber FROM Order WHERE OrderNumber = :orderNumber];
                    String order_name = orders[0].OrderNumber;
                    Id orderId = orders[0].Id;
        
                    Map createShipmentParameter = new Map();
                    createShipmentParameter.put('customAddressId', 'a0G0b00000SVhR0EAL');
                    createShipmentParameter.put('recordId', orderId);
                    createShipmentParameter.put('userId', '0050b000004O0fI');
                    createShipmentParameter.put('encryptedKey', 'D3dr0Jr4sjVCeZzhzlX2eYOKXSFu1qsEpoNhDwB/KOtPtCLBY7FXkbHx6efEtvm7');
        
                    String jsonParams = JSON.serialize(createShipmentParameter);
        
                    Map shipResult = zkmulti.ShipmentInterface.createShipmentSync(JSON.serialize(createShipmentParameter));
        
                    Id shipment_id = (Id)shipResult.get('shipment_id');
        
                    List labels = [SELECT Id FROM Attachment WHERE ParentId =: shipment_id];
                    r.labelUrl = 'https://YOUR_DOMAIN.na57.force.com/bot/apex/PopupImage?img_id='+labels[0].Id;
                }
                catch (Exception e) {
                    r.labelUrl = e.getStackTraceString();
                }
                resp.add(r);
        
                return resp;
            }
        
            public without sharing class Request {
                @InvocableVariable(label='orderNumber' required=true)
                public String orderNumber;
            }
        
            public without sharing class Response {
                @InvocableVariable(label='labelUrl' required=true)
                public String labelUrl;
            }
        }
    

Contact

If you would like to find out more then please contact us and we will be happy to help