File size: 1,107 Bytes
64382cc 1366db9 64382cc 1366db9 64382cc 1366db9 64382cc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from typing import Dict, Optional, Any
from bot_definitions import BotType, call_transfer, simple_dialin, simple_dialout, voicemail_detection
class BotRegistry:
def __init__(self):
self.bots: Dict[str, BotType] = {
"call_transfer": call_transfer,
"simple_dialin": simple_dialin,
"simple_dialout": simple_dialout,
"voicemail_detection": voicemail_detection,
}
def get_bot(self, name: str) -> Optional[BotType]:
return self.bots.get(name)
def detect_bot_type(self, body: Dict[str, Any]) -> Optional[str]:
for bot in self.bots.values():
if bot.config_key in body:
return bot.name
if all(key in body for key in ["From", "To", "callId", "callDomain"]):
return "call_transfer"
return None
def setup_configuration(self, config: Dict[str, Any]) -> Dict[str, Any]:
body = {}
bot_name = config.get("bot_type")
bot = self.get_bot(bot_name)
if bot:
body[bot.config_key] = config.get("settings", {})
return body |