class_docstr: Handles CRUD operations at the database level for Chatbots
class_docstr_tok: ["Handles","CRUD","operations","at","the","database","level","for","Chatbots"]
docstr: Gets a chatbot by name.
  
  Parameters:
      chatbot_name (str): The name of the chatbot
      project_name (str): The name of the containing project
  
  Returns:
      bot (db.ChatBots): The database chatbot object
docstr_tok: ["Gets","a","chatbot","by","name",".","Parameters",":","chatbot_name","(","str",")",":","The","name","of","the","chatbot","project_name","(","str",")",":","The","name","of","the","containing","project","Returns",":","bot","(","db.ChatBots",")",":","The","database","chatbot","object"]
code: def get_chatbot(
      self, chatbot_name: str, project_name: str = "mindsdb"
  ) -> db.ChatBots:
      """
      Gets a chatbot by name.
  
      Parameters:
          chatbot_name (str): The name of the chatbot
          project_name (str): The name of the containing project
  
      Returns:
          bot (db.ChatBots): The database chatbot object
      """
  
      project = self.project_controller.get(name=project_name)
  
      query = (
          db.session.query(db.ChatBots, db.Tasks)
          .join(db.Tasks, db.ChatBots.id == db.Tasks.object_id)
          .filter(
              db.ChatBots.name == chatbot_name,
              db.ChatBots.project_id == project.id,
              db.Tasks.object_type == self.OBJECT_TYPE,
              db.Tasks.company_id == ctx.company_id,
          )
      )
  
      query_result = query.first()
      if query_result is None:
          return None
      bot, task = query_result
  
      # Include DB, Agent, and Task information in response.
      session = SessionController()
      database_names = {
          i["id"]: i["name"]
          for i in session.database_controller.get_list()
      }
  
      agent = self.agents_controller.get_agent_by_id(bot.agent_id)
      agent_obj = agent.as_dict() if agent is not None else None
      bot_obj = {
          "id": bot.id,
          "name": bot.name,
          "project": project_name,
          "agent": agent_obj,
          "database_id": bot.database_id,  # TODO remove in future
          "database": database_names.get(bot.database_id, "?"),
          "model_name": bot.model_name,
          "params": bot.params,
          "created_at": bot.created_at,
          "is_running": task.active,
          "last_error": task.last_error,
      }
      return bot_obj
  
file_path: mindsdb/mindsdb/interfaces/chatbot/chatbot_controller.py
imports: from typing import Dict, List
  from mindsdb.interfaces.agents.agents_controller import AgentsController
  from mindsdb.interfaces.database.projects import ProjectController
  from mindsdb.interfaces.storage import db
  from mindsdb.utilities.context import context
  from mindsdb.api.executor.controllers.session_controller import SessionController
  from mindsdb.utilities.config import Config
label_desc: Use image node_id 2 for calling the ChatBotController obj's underlying member method code with example usage: obj.get_chatbot(chatbot_name, project_name) and returns: bot_obj, None