Coverage for mindsdb / integrations / handlers / symbl_handler / symbl_handler.py: 0%
45 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-21 00:36 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-21 00:36 +0000
1import symbl
2from mindsdb.integrations.handlers.symbl_handler.symbl_tables import (
3 GetConversationTable,
4 GetMessagesTable,
5 GetTopicsTable,
6 GetQuestionsTable,
7 GetAnalyticsTable,
8 GetActionItemsTable,
9 GetFollowUpsTable
10)
11from mindsdb.integrations.libs.api_handler import APIHandler
12from mindsdb.integrations.libs.response import (
13 HandlerStatusResponse as StatusResponse,
14)
16from mindsdb.utilities import log
17from mindsdb_sql_parser import parse_sql
20logger = log.getLogger(__name__)
23class SymblHandler(APIHandler):
24 """The Symbl handler implementation"""
26 def __init__(self, name: str, **kwargs):
27 """Initialize the Symbl handler.
29 Parameters
30 ----------
31 name : str
32 name of a handler instance
33 """
34 super().__init__(name)
36 connection_data = kwargs.get("connection_data", {})
37 self.connection_data = connection_data
38 self.credentials = {"app_id": self.connection_data.get("app_id"), "app_secret": self.connection_data.get("app_secret")}
39 self.kwargs = kwargs
40 self.is_connected = False
42 conversation_id_data = GetConversationTable(self)
43 self._register_table("get_conversation_id", conversation_id_data)
45 messages_data = GetMessagesTable(self)
46 self._register_table("get_messages", messages_data)
48 topics_data = GetTopicsTable(self)
49 self._register_table("get_topics", topics_data)
51 question_data = GetQuestionsTable(self)
52 self._register_table("get_questions", question_data)
54 analytics_data = GetAnalyticsTable(self)
55 self._register_table("get_analytics", analytics_data)
57 ai_data = GetActionItemsTable(self)
58 self._register_table("get_action_items", ai_data)
60 follow_up_data = GetFollowUpsTable(self)
61 self._register_table("get_follow_ups", follow_up_data)
63 def connect(self) -> StatusResponse:
64 """Set up the connection required by the handler.
66 Returns
67 -------
68 StatusResponse
69 connection object
70 """
71 resp = StatusResponse(False)
72 try:
73 symbl.AuthenticationToken.get_access_token(self.credentials)
74 resp.success = True
75 self.is_connected = True
76 except Exception as ex:
77 resp.success = False
78 resp.error_message = ex
79 self.is_connected = False
80 return resp
82 def check_connection(self) -> StatusResponse:
83 """Check connection to the handler.
85 Returns
86 -------
87 StatusResponse
88 Status confirmation
89 """
90 return self.connect()
92 def native_query(self, query: str) -> StatusResponse:
93 """Receive and process a raw query.
95 Parameters
96 ----------
97 query : str
98 query in a native format
100 Returns
101 -------
102 StatusResponse
103 Request status
104 """
105 ast = parse_sql(query)
106 return self.query(ast)