In this article we explain how to reset the Pushtopic being used by our chat component after a package update or for troubleshooting purposes.
You need to be an admin or have an equivalent role in order to be able to do these steps.
Also please make sure you notify your agents when doing this step because they will need to delete the browser's cache.
In order to reset the Pushtopic you need to:
1 - Go to Developer Console:
2 - Open an anonymous window:
3 - Paste the following code:
delete [SELECT Id FROM PushTopic WHERE Name = 'AllTRs' limit 1];
4 - Click execute:
This will delete the pushtopic record being used by our Chat Component. The pushtopic record will then be recreated with the last version as soon as an Agent starts a chat conversation.
Creating a new Pushtopic
In case the Pushtopic is not automatically recreated after deletion, you can create a new one. In order to create the PushTopic repeat the steps above to access the developer console and open the anonymous window. Then:
1 - Paste the following code:
PushTopic trsPushTopic = new PushTopic();
trsPushTopic.ApiVersion = 51.0;
trsPushTopic.Name = 'AllTRs';
trsPushTopic.Description = 'Fetches all the translation requests';
trsPushTopic.Query = 'SELECT Id, unbabelapi__Unbabel_Status__c, unbabelli__Unbabel_ChatKey__c, unbabelapi__Unbabel_sObject_Id__c,unbabelapi__Unbabel_Translation_Requested_Datetime__c,unbabelli__Unbabel_Inbound__c,unbabelli__Unbabel_Order__c,unbabelapi__Unbabel_From_Language__c,unbabelapi__Unbabel_To_Language__c,CreatedById ' +
'FROM unbabelapi__Unbabel_Translation_Request__c ' +
'WHERE unbabelapi__Unbabel_sObject__c=\'UnbabelChatMessage\' ' +
'AND CreatedDate > LAST_WEEK';
trsPushTopic.NotifyForFields = 'Referenced';
trsPushTopic.NotifyForOperationCreate = false;
trsPushTopic.NotifyForOperationUpdate = true;
trsPushTopic.NotifyForOperationDelete = false;
trsPushTopic.NotifyForOperationUndelete = false;
2 - Click execute. This will create the PushTopic. In order to validate it you can run the query below:
SELECT Id FROM PushTopic WHERE Name = 'AllTRs' limit 1