Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

refacto: EVENTS_DOMAIN var management in Python

Clémence Lesnéd66588c88fa3
diff --git a/helpers/config_models/api.py b/helpers/config_models/api.py
index 2d3de94..3b86189 100644
--- a/helpers/config_models/api.py
+++ b/helpers/config_models/api.py
@@ -3,5 +3,6 @@ from pydantic import BaseModel, Field
class ApiModel(BaseModel):
+ events_domain: str = environ["EVENTS_DOMAIN"]
root_path: str = ""
version: str = Field(default=environ["VERSION"], frozen=True)
diff --git a/main.py b/main.py
index 55e466c..c7aa9b3 100644
--- a/main.py
+++ b/main.py
@@ -75,10 +75,8 @@ sms_client = SmsClient(
)
db = sqlite3.connect(".local.sqlite", check_same_thread=False)
-EVENTS_DOMAIN = environ.get("EVENTS_DOMAIN").strip("/")
-assert EVENTS_DOMAIN, "EVENTS_DOMAIN environment variable is not set"
-CALL_EVENT_URL = f"{EVENTS_DOMAIN}/call/event"
-CALL_INBOUND_URL = f"{EVENTS_DOMAIN}/call/inbound"
+CALL_EVENT_URL = f"{CONFIG.api.events_domain}/call/event"
+CALL_INBOUND_URL = f"{CONFIG.api.events_domain}/call/inbound"
class Context(str, Enum):