File size: 1,308 Bytes
c5d854a
 
1366db9
 
c5d854a
 
 
1366db9
 
 
 
c5d854a
1366db9
 
c5d854a
 
 
 
 
 
 
 
 
1366db9
 
 
 
 
 
 
c5d854a
 
 
 
1366db9
 
c5d854a
1366db9
 
c5d854a
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
from typing import Dict, Any, Optional
from bot_definitions import bot_registry


def determine_room_capabilities(body: Dict[str, Any]) -> Dict[str, bool]:
    bot_type = bot_registry.detect_bot_type(body)
    bot = bot_registry.get_bot(bot_type)
    capabilities = {
        "enable_dialin": False,
        "enable_dialout": False,
    }
    if not bot:
        return capabilities

    if bot.name == "call_transfer":
        call_transfer_config = body.get("call_transfer", {})
        capabilities["enable_dialin"] = True
        if call_transfer_config.get("mode") == "dialout":
            capabilities["enable_dialout"] = True
    elif bot.name == "simple_dialin":
        capabilities["enable_dialin"] = True
    elif bot.name in ["simple_dialout", "voicemail_detection"]:
        capabilities["enable_dialout"] = True

    return capabilities


async def process_dialin_request(data: Dict[str, Any]) -> Dict[str, Any]:
    body = {
        "dialin_settings": {
            "callId": data.get("callId"),
            "callDomain": data.get("callDomain"),
            "From": data.get("From"),
            "To": data.get("To"),
        }
    }
    return body


def ensure_prompt_config(body: Dict[str, Any]) -> Dict[str, Any]:
    if "prompts" not in body:
        body["prompts"] = []
    return body