Get Salesforce BOT Version Activation Status using Apex

Get Salesforce BOT Version Activation Status using Apex

Use the following apex code as a reference to check whether the BOT Version is activated or deactivated and build version.

Sample Apex Code:

Id BOTVersionId = '0X9Ho000000l3uFKAQ';

try {
    ConnectApi.BotVersionActivationInfo activationInfo =
        ConnectApi.BotVersionActivation.getVersionActivationInfo( BOTVersionId );
    
    System.debug( 
        'Chatbot Version Activation Info' + 
        activationInfo.toString()
    );
    
} catch ( Exception e ) {
    
    System.debug( '--- General Exception ---' );
    System.debug( 'Message: ' + e.getMessage() );
    
}

We can use the same apex code to get the Agentforce Agent Version Status. We can check whether it is activated or deactivated.

You can use the following SOQL to query the BotVersion object/entity.

SELECT Id, DeveloperName, BotDefinition.MasterLabel, 
BotDefinition.DeveloperName, BotDefinition.Type
FROM BotVersion

Leave a Reply