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

quality: Validate phone numbers in the conf

Clémence Lesnéaa2af2ece2ea
diff --git a/helpers/config_models/communication_service.py b/helpers/config_models/communication_service.py
index 347d36c..aeab3ec 100644
--- a/helpers/config_models/communication_service.py
+++ b/helpers/config_models/communication_service.py
@@ -1,8 +1,13 @@
from pydantic import BaseModel, SecretStr
+from pydantic_extra_types.phone_numbers import PhoneNumber
+
+
+# E164 is standard accross all Microsoft services
+PhoneNumber.phone_format = "E164"
class CommunicationServiceModel(BaseModel):
access_key: SecretStr
endpoint: str
- phone_number: str
+ phone_number: PhoneNumber
voice_name: str
diff --git a/helpers/config_models/twilio.py b/helpers/config_models/twilio.py
index 21bc044..0629a84 100644
--- a/helpers/config_models/twilio.py
+++ b/helpers/config_models/twilio.py
@@ -1,7 +1,12 @@
from pydantic import BaseModel, SecretStr
+from pydantic_extra_types.phone_numbers import PhoneNumber
+
+
+# E164 is standard accross all Microsoft services
+PhoneNumber.phone_format = "E164"
class TwilioModel(BaseModel):
account_sid: str
auth_token: SecretStr
- phone_number: str
+ phone_number: PhoneNumber
diff --git a/helpers/config_models/workflow.py b/helpers/config_models/workflow.py
index ae9fdb3..961a9e4 100644
--- a/helpers/config_models/workflow.py
+++ b/helpers/config_models/workflow.py
@@ -1,8 +1,13 @@
from pydantic import BaseModel
+from pydantic_extra_types.phone_numbers import PhoneNumber
+
+
+# E164 is standard accross all Microsoft services
+PhoneNumber.phone_format = "E164"
class WorkflowModel(BaseModel):
- agent_phone_number: str
+ agent_phone_number: PhoneNumber
bot_company: str
bot_name: str
conversation_lang: str
diff --git a/requirements.txt b/requirements.txt
index 8931330..8a1c672 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,6 +5,8 @@ azure-identity==1.15.0
azure-mgmt-eventgrid==10.2.0
fastapi==0.108.0
openai==1.7.0
+phonenumbers==8.13.27
+pydantic-extra-types==2.4.0
python-dotenv==1.0.0
pyyaml==6.0.1
twilio==8.11.0