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

fix: Use langs from call model, not config

Clémence Lesnéb4be8034924f
diff --git a/app/helpers/call_events.py b/app/helpers/call_events.py
index 6c2ae68..4b50ebb 100644
--- a/app/helpers/call_events.py
+++ b/app/helpers/call_events.py
@@ -750,8 +750,8 @@ async def _handle_ivr_language(
If only one language is available, selects it by default. Else, plays the IVR prompt.
"""
# If only one language is available, skip the IVR
- if len(CONFIG.conversation.initiate.lang.availables) == 1:
- short_code = CONFIG.conversation.initiate.lang.availables[0].short_code
+ if len(call.initiate.lang.availables) == 1:
+ short_code = call.initiate.lang.availables[0].short_code
logger.info("Only one language available, selecting %s by default", short_code)
await on_ivr_recognized(
call=call,
@@ -773,7 +773,7 @@ async def _handle_ivr_language(
DtmfTone.NINE,
]
choices = []
- for i, lang in enumerate(CONFIG.conversation.initiate.lang.availables):
+ for i, lang in enumerate(call.initiate.lang.availables):
choices.append(
RecognitionChoice(
label=lang.short_code,
diff --git a/app/models/call.py b/app/models/call.py
index 3a91c81..1e8a7c9 100644
--- a/app/models/call.py
+++ b/app/models/call.py
@@ -110,15 +110,12 @@ class CallStateModel(CallGetModel, extra="ignore"):
@computed_field
@property
def lang(self) -> LanguageEntryModel: # pyright: ignore
- from app.helpers.config import CONFIG
-
- lang = CONFIG.conversation.initiate.lang
- default = lang.default_lang
+ default = self.initiate.lang.default_lang
if self.lang_short_code:
return next(
(
lang
- for lang in lang.availables
+ for lang in self.initiate.lang.availables
if lang.short_code == self.lang_short_code
),
default,