Skip to main content

Dear All,  With Enhanced Chat (MIAW) the messagingSession record do not contain the Chat Transcript. It is important for our business to produce the ChatTranscript and the only way I've found is via REST API on the /converationEntries API.   My idea is then to create a batchable APEX job so that night time, the chat transcript are produced.   I am struggling to have the UnitTest pass.   Has anyone been successful to produce the ChatTranscript for the new Enhanced chat and link it to the MessagingSession record in any way  or another?    I'm open to suggestions.  GC   

@* Salesforce Developers * 

3 risposte
  1. 6 mag, 13:39

    @Giancarlo Amati  I hope it may help you.  Sample test method code is provided below. 

     

     // Create MessagingSession with file.                

             MessagingSession mSession = new MessagingSession(); 

             mSession.messagingChannelId = channel.Id; 

             mSession.MessagingEndUserId = endUser.Id; 

             mSession.Origin = 'OptIn';          

             mSession.Status = 'Ended';           

             insert mSession;  

              

             List<Conversationentry> CElist = new List<Conversationentry>(); 

             for(Integer i=0; i<=300; i++){ 

                 Conversationentry newCV = new Conversationentry(); 

                 newCV.ConversationId =mSession.id; 

                 newCV.EntryType = 'Text'; 

                 newCV.ActorName = 'Test'+i; 

                 newCV.EntryTime = system.today(); 

                 newCV.ActorType = 'System'; 

                 newCV.Seq = i;  

                 CElist.add(newCV); 

             } 

             insert CElist;     

              

             ContentVersion content = new ContentVersion();  

             content.Title = 'MyHeader_Picture1';  

             content.PathOnClient = '/'+content.Title+'.jpg';  

             Blob bodyBlob = Blob.valueOf('Unit Test ContentVersion Body');  

             content.VersionData = bodyBlob;  

             content.origin = 'H'; 

             Test.startTest(); 

             insert content; 

              

             Id contentdocumentidd = [select contentdocumentid from contentversion where   id=:content.id].contentdocumentid; 

             ContentDocumentLink contentlink = new ContentDocumentLink(); 

             contentlink.LinkedEntityId = mSession.id; 

             contentlink.contentdocumentid = contentdocumentidd; 

             contentlink.ShareType = 'I'; 

             contentlink.Visibility = 'AllUsers'; 

             insert contentlink; 

             Test.stopTest(); 

             mSession.CaseId = caseRec.id; 

             update mSession;  

     

    We have completed the Enhanced Messaging Conversations to Case Comments implementation. If you review the post below, it should give you a good understanding of the approach. I hope this will be helpful. 

     

    Enhanced Messaging Conversations to Case Comments in Salesforce Using Connect API 

    https://medium.com/@ramakrishnanayyanar/enhanced-messaging-conversations-to-case-comments-in-salesforce-using-connect-api-842a5275bd00

     

    Thanks, 

    Ramki

0/9000