The Internet of Things, or IoT, is changing practically every aspect of modern life and entering both the business and residential domains. The proliferation of IoT has led to a rise in the frequency of cyber catastrophes. Attackers are using new methods or changing old ones, making the danger more sophisticated. The threat landscape that security professionals face is dynamic, complex, and diversified. This paper proposes a novel approach to enhance Internet of Things applications by fusing the swarm intelligence of Salp Swarm Algorithms (SSA) with the predictive power of Random Forest (RF) and Decision Tree (DT) models. Salp Swarm Algorithms simulate the cooperative behavior of salps in the natural world, wherein individual agents coordinate their actions to achieve common goals. This work uses SSA to optimize the Random Forest and Decision Tree model training process in an IoT context. SSA's collaborative nature makes it easier to explore the solution space effectively, which enhances the models' ability to capture the complex correlations found in IoT data. The effectiveness of the model is evaluated. We were able to attain a maximum accuracy of 95.54% for the Decision Tree of the OT-MQTT dataset and 96.19% for the random forest.