ConnectApi.BotVersionActivation.updateVersionStatus() can be used to Activate or Deactivate Salesforce BOT Version using Apex.
Please check the following sample apex code for your reference.
Sample Apex Code:
Id BOTVersionId = '0X9Ho000000l3uFKAQ';
try {
ConnectApi.BotVersionActivationInfo activationInfo =
ConnectApi.BotVersionActivation.updateVersionStatus (
BOTVersionId, ConnectApi.BotVersionActivationStatus.InActive,
null
);
System.debug(
'Chatbot Version Activation Info' +
activationInfo.toString()
);
} catch ( Exception e ) {
System.debug( '--- General Exception ---' );
System.debug( 'Message: ' + e.getMessage() );
}
Note:
You can use:
ConnectApi.BotVersionActivationStatus.Active – to activate
ConnectApi.BotVersionActivationStatus.InActive – to deactivate
Agentforce Agent and Einstein BOT can be activated or deactivated using this approach.
Salesforce Article:
You can use the following SOQL to query the BotVersion object/entity.
SELECT Id, DeveloperName, BotDefinition.MasterLabel,
BotDefinition.DeveloperName, BotDefinition.Type
FROM BotVersion
Salesforce Article: