mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-28 08:49:42 +02:00
* feat(twilio): add Answering Machine Detection (AMD) support via telephony config Closes #339 * chore: regenerate OpenAPI spec to fix drift-check The openapi.json snapshot had drifted from the FastAPI app definition because main gained new organization endpoints (billing, credits, context) after this branch was created. Regenerate it with 'python -m scripts.dump_docs_openapi' to bring it back in sync. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add provider-level AMD hooks * fix: handle db error while persisting amd result --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Sabiha Khan <sabihak89@gmail.com> Co-authored-by: Sabiha Khan <87858386+chewwbaka@users.noreply.github.com>
86 lines
2.3 KiB
Python
86 lines
2.3 KiB
Python
"""Twilio telephony provider package."""
|
|
|
|
from typing import Any, Dict
|
|
|
|
from api.services.telephony.registry import (
|
|
ProviderSpec,
|
|
ProviderUIField,
|
|
ProviderUIMetadata,
|
|
register,
|
|
)
|
|
|
|
from .config import TwilioConfigurationRequest, TwilioConfigurationResponse
|
|
from .provider import TwilioProvider
|
|
from .transport import create_transport
|
|
|
|
|
|
def _config_loader(value: Dict[str, Any]) -> Dict[str, Any]:
|
|
return {
|
|
"provider": "twilio",
|
|
"account_sid": value.get("account_sid"),
|
|
"auth_token": value.get("auth_token"),
|
|
"from_numbers": value.get("from_numbers", []),
|
|
"amd_enabled": value.get("amd_enabled", False),
|
|
}
|
|
|
|
|
|
_UI_METADATA = ProviderUIMetadata(
|
|
display_name="Twilio",
|
|
docs_url="https://docs.dograh.com/integrations/telephony/twilio",
|
|
fields=[
|
|
ProviderUIField(
|
|
name="account_sid",
|
|
label="Account SID",
|
|
type="text",
|
|
sensitive=True,
|
|
description="Twilio Account SID (starts with AC)",
|
|
),
|
|
ProviderUIField(
|
|
name="auth_token",
|
|
label="Auth Token",
|
|
type="password",
|
|
sensitive=True,
|
|
description="Twilio Auth Token",
|
|
),
|
|
ProviderUIField(
|
|
name="from_numbers",
|
|
label="Phone Numbers",
|
|
type="string-array",
|
|
description="E.164-formatted Twilio phone numbers used for outbound calls",
|
|
),
|
|
ProviderUIField(
|
|
name="amd_enabled",
|
|
label="Answering Machine Detection",
|
|
type="boolean",
|
|
description=(
|
|
"Detect whether outbound calls are answered by a person or "
|
|
"machine. Twilio may bill AMD as an additional per-call feature."
|
|
),
|
|
),
|
|
],
|
|
)
|
|
|
|
|
|
SPEC = ProviderSpec(
|
|
name="twilio",
|
|
provider_cls=TwilioProvider,
|
|
config_loader=_config_loader,
|
|
transport_factory=create_transport,
|
|
transport_sample_rate=8000,
|
|
config_request_cls=TwilioConfigurationRequest,
|
|
ui_metadata=_UI_METADATA,
|
|
config_response_cls=TwilioConfigurationResponse,
|
|
account_id_credential_field="account_sid",
|
|
)
|
|
|
|
|
|
register(SPEC)
|
|
|
|
|
|
__all__ = [
|
|
"SPEC",
|
|
"TwilioConfigurationRequest",
|
|
"TwilioConfigurationResponse",
|
|
"TwilioProvider",
|
|
"create_transport",
|
|
]
|