Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
fix: Claim data expiration detection
Clémence Lesnéacc43741405e
diff --git a/persistence/cosmos.py b/persistence/cosmos.pyindex c030245..f55cec7 100644--- a/persistence/cosmos.py+++ b/persistence/cosmos.py@@ -87,21 +87,12 @@ class CosmosStore(IStore):async with self._use_db() as db:items = db.query_items(max_item_count=1,- query="SELECT * FROM c WHERE (STRINGEQUALS(c.phone_number, @phone_number, true) OR STRINGEQUALS(c.claim.policyholder_phone, @phone_number, true)) AND c.created_at < @date_limit ORDER BY c.created_at DESC",+ query=f"SELECT * FROM c WHERE (STRINGEQUALS(c.phone_number, @phone_number, true) OR STRINGEQUALS(c.claim.policyholder_phone, @phone_number, true)) AND c.created_at >= DATETIMEADD('hh', -{CONFIG.workflow.conversation_timeout_hour}, GETCURRENTDATETIME()) ORDER BY c.created_at DESC",parameters=[{"name": "@phone_number","value": phone_number,- },- {- "name": "@date_limit",- "value": str(- datetime.utcnow()- + timedelta(- hours=CONFIG.workflow.conversation_timeout_hour- )- ),- },+ }],)raw = await anext(items)diff --git a/persistence/sqlite.py b/persistence/sqlite.pyindex 1f0a2bd..eea6458 100644--- a/persistence/sqlite.py+++ b/persistence/sqlite.py@@ -59,7 +59,7 @@ class SqliteStore(IStore):_logger.debug(f"Loading last call for {phone_number}")async with self._use_db() as db:cursor = await db.execute(- f"SELECT data FROM {self._config.table} WHERE (JSON_EXTRACT(data, '$.phone_number') LIKE ? OR JSON_EXTRACT(data, '$.claim.policyholder_phone') LIKE ?) AND DATETIME(JSON_EXTRACT(data, '$.created_at')) < DATETIME('now', '{CONFIG.workflow.conversation_timeout_hour} hours') ORDER BY DATETIME(JSON_EXTRACT(data, '$.created_at')) DESC LIMIT 1",+ f"SELECT data FROM {self._config.table} WHERE (JSON_EXTRACT(data, '$.phone_number') LIKE ? OR JSON_EXTRACT(data, '$.claim.policyholder_phone') LIKE ?) AND DATETIME(JSON_EXTRACT(data, '$.created_at')) >= DATETIME('now', '-{CONFIG.workflow.conversation_timeout_hour} hours') ORDER BY DATETIME(JSON_EXTRACT(data, '$.created_at')) DESC LIMIT 1",(phone_number, # data.phone_numberphone_number, # data.claim.policyholder_phone