Exit early when running an automation if the conversation for the automation does not exist.

This commit is contained in:
sabaimran 2024-11-10 19:22:21 -08:00
parent 7468f6a6ed
commit a5e2b9e745

View file

@ -1582,6 +1582,11 @@ def scheduled_chat(
# encode the conversation_id to avoid any issues with special characters # encode the conversation_id to avoid any issues with special characters
query_dict["conversation_id"] = [quote(str(conversation_id))] query_dict["conversation_id"] = [quote(str(conversation_id))]
# validate that the conversation id exists. If not, delete the automation and exit.
if not ConversationAdapters.get_conversation_by_id(conversation_id):
AutomationAdapters.delete_automation(user, job_id)
return
# Restructure the original query_dict into a valid JSON payload for the chat API # Restructure the original query_dict into a valid JSON payload for the chat API
json_payload = {key: values[0] for key, values in query_dict.items()} json_payload = {key: values[0] for key, values in query_dict.items()}