Skip to content

Commit

Permalink
Callback action fixes (#1408)
Browse files Browse the repository at this point in the history
* changed conversation fetching for chat history and chat client to use flattened data properly

* added live_agent_enabled flag to chat client config

* changed parameter raise error True for __check_for_form_and_action_existance in MongoProcessor

* callback action

* Added callback action and its related components and basic test cases related to the same.

* rearrangement and added more tests

* removed timestamp from CallbackData causing json dump inside trigger_lambda fail

* typo fix flatten -> flattened

---------

Co-authored-by: spandan.mondal <[email protected]>
  • Loading branch information
hasinaxp and spandan.mondal authored Aug 7, 2024
1 parent 10f3b16 commit 58bd69d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions kairon/async_callback/channel_message_dispacher.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def handle_instagram(bot: str, config, sender: str, message: Any):
async def handle_default(bot: str, config, sender: str, message: Any, channel: str = 'default'):
chat_database_collection = MessageBroadcastProcessor.get_db_client(bot)
chat_database_collection.insert_one({
"type": "flatten",
"type": "flattened",
"tag": 'callback_message',
"conversation_id": uuid7().hex,
"timestamp": time.time(),
Expand Down Expand Up @@ -86,7 +86,7 @@ async def dispatch_message(bot: str, sender: str, message: str, channel: str):

chat_database_collection = MessageBroadcastProcessor.get_db_client(bot)
chat_database_collection.insert_one({
"type": "flatten",
"type": "flattened",
"tag": 'callback_message',
"conversation_id": uuid7().hex,
"timestamp": time.time(),
Expand Down
4 changes: 4 additions & 0 deletions kairon/shared/callback/data_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from kairon import Utility
from kairon.exceptions import AppException
from kairon.shared.actions.data_objects import CallbackActionConfig
from kairon.shared.data.audit.data_objects import Auditlog
from kairon.shared.data.signals import push_notification
from fernet import Fernet
Expand Down Expand Up @@ -115,6 +116,9 @@ def edit(bot: str, name: str, **kwargs):
@staticmethod
def delete_entry(bot: str, name: str):
check_nonempty_string(name)
callback_action_count = CallbackActionConfig.objects(bot=bot, callback_name=name).count()
if callback_action_count > 0:
raise AppException(f"Cannot delete Callback Configuration '{name}' as it is attached to some callback action!")
config = CallbackConfig.objects(bot=bot, name__iexact=name).first()
if not config:
raise AppException(f"Callback Configuration with name '{name}' does not exist!")
Expand Down
2 changes: 0 additions & 2 deletions kairon/shared/data/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8004,8 +8004,6 @@ def edit_callback_action(self, request_data: dict, bot: Text, user: Text):

update_query = {}
for key, value in request_data.items():
if not value and key != 'dispatch_bot_response':
continue
if key == 'metadata_list':
value = [HttpActionRequestBody(**param)for param in value] or []

Expand Down

0 comments on commit 58bd69d

Please sign in to comment.