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: Last updated call was not every time sorted

Clémence Lesné121334487031
diff --git a/main.py b/main.py
index ac727c2..ddd6c74 100644
--- a/main.py
+++ b/main.py
@@ -999,7 +999,7 @@ async def get_call_by_id(call_id: UUID) -> Optional[CallModel]:
async def get_last_call_by_phone_number(phone_number: str) -> Optional[CallModel]:
async with aiosqlite.connect(CONFIG.database.sqlite_path) as db:
cursor = await db.execute(
- f"SELECT data FROM calls WHERE phone_number = ? AND DATETIME(created_at) > DATETIME('now', '-{CONFIG.workflow.conversation_timeout_hour} hours') ORDER BY created_at DESC LIMIT 1",
+ f"SELECT data FROM calls WHERE phone_number = ? AND DATETIME(created_at) > DATETIME('now', '-{CONFIG.workflow.conversation_timeout_hour} hours') ORDER BY DATETIME(created_at) DESC LIMIT 1",
(phone_number,),
)
row = await cursor.fetchone()