-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Whatsapp flows #1110
Whatsapp flows #1110
Conversation
WalkthroughWalkthroughThe update introduces a new message handling logic for "nfm_reply" interactive messages within the WhatsApp channel handler, along with enhanced integration testing for WhatsApp message flows. Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (2)
- kairon/chat/handlers/channels/whatsapp.py (1 hunks)
- tests/integration_test/chat_service_test.py (1 hunks)
Additional comments: 2
kairon/chat/handlers/channels/whatsapp.py (2)
43-47: The construction of
response_json
usingjson.dumps
seems correct, but it's important to ensure that themessage["interactive"][interactive_type]['response_json']
is always going to be a valid JSON object before attempting to serialize it. If there's any chance it could be malformed or not present, this could raise an exception.47-47: The formatted text
f"/k_flow_msg{response_json}"
is being created but it's not clear if this format is consistent with the rest of the application. Verify that this format is expected and handled correctly downstream.
@responses.activate | ||
def test_whatsapp_valid_flows_message_request(): | ||
responses.reset() | ||
def _mock_validate_hub_signature(*args, **kwargs): | ||
return True | ||
|
||
with patch.object(MessengerHandler, "validate_hub_signature", _mock_validate_hub_signature): | ||
with mock.patch("kairon.chat.handlers.channels.whatsapp.Whatsapp._handle_user_message", | ||
autospec=True) as whatsapp_msg_handler: | ||
request_json = { | ||
'object': 'whatsapp_business_account', | ||
'entry': [{ | ||
'id': '147142368486217', | ||
'changes': [{ | ||
'value': { | ||
'messaging_product': 'whatsapp', | ||
'metadata': { | ||
'display_phone_number': '918657011111', | ||
'phone_number_id': '142427035629239' | ||
}, | ||
'contacts': [{ | ||
'profile': { | ||
'name': 'Mahesh' | ||
}, | ||
'wa_id': '919515991111' | ||
}], | ||
'messages': [{ | ||
'context': { | ||
'from': '918657011111', | ||
'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAERgSMjVGRjYwODI3RkMyOEQ0NUM1AA==' | ||
}, | ||
'from': '919515991111', | ||
'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAEhggQTRBQUYyODNBQkMwNEIzRDQ0MUI1ODkyMTE2NTMA', | ||
'timestamp': '1703257297', | ||
'type': 'interactive', | ||
'interactive': { | ||
'type': 'nfm_reply', | ||
'nfm_reply': { | ||
'response_json': '{"flow_token":"AQBBBBBCS5FpgQ_cAAAAAD0QI3s.","firstName":"Mahesh ","lastName":"Sattala ","pincode":"523456","district":"Bangalore ","houseNumber":"5-6","dateOfBirth":"1703257240046","source":"SOCIAL_MEDIA","landmark":"HSR Layout ","email":"[email protected]"}', | ||
'body': 'Sent', | ||
'name': 'flow' | ||
} | ||
} | ||
}] | ||
}, | ||
'field': 'messages' | ||
}] | ||
}] | ||
} | ||
response = client.post( | ||
f"/api/bot/whatsapp/{bot}/{token}", | ||
headers={"hub.verify_token": "valid"}, | ||
json=request_json | ||
) | ||
actual = response.json() | ||
assert actual == 'success' | ||
assert len(whatsapp_msg_handler.call_args[0]) == 5 | ||
print(whatsapp_msg_handler.call_args[0][1]) | ||
assert whatsapp_msg_handler.call_args[0][1] == '/k_flow_msg{"nfm_reply": "{\\"flow_token\\":\\"AQBBBBBCS5FpgQ_cAAAAAD0QI3s.\\",\\"firstName\\":\\"Mahesh \\",\\"lastName\\":\\"Sattala \\",\\"pincode\\":\\"523456\\",\\"district\\":\\"Bangalore \\",\\"houseNumber\\":\\"5-6\\",\\"dateOfBirth\\":\\"1703257240046\\",\\"source\\":\\"SOCIAL_MEDIA\\",\\"landmark\\":\\"HSR Layout \\",\\"email\\":\\"[email protected]\\"}"}' | ||
assert whatsapp_msg_handler.call_args[0][2] == '919515991111' | ||
metadata = whatsapp_msg_handler.call_args[0][3] | ||
metadata.pop("timestamp") | ||
print(metadata) | ||
assert metadata == { | ||
'context': {'from': '918657011111', 'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAERgSMjVGRjYwODI3RkMyOEQ0NUM1AA=='}, | ||
'from': '919515991111', 'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAEhggQTRBQUYyODNBQkMwNEIzRDQ0MUI1ODkyMTE2NTMA', | ||
'type': 'interactive', | ||
'interactive': { | ||
'type': 'nfm_reply', 'nfm_reply': { | ||
'response_json': '{"flow_token":"AQBBBBBCS5FpgQ_cAAAAAD0QI3s.","firstName":"Mahesh ","lastName":"Sattala ","pincode":"523456","district":"Bangalore ","houseNumber":"5-6","dateOfBirth":"1703257240046","source":"SOCIAL_MEDIA","landmark":"HSR Layout ","email":"[email protected]"}', | ||
'body': 'Sent', 'name': 'flow'}}, | ||
'is_integration_user': True, 'bot': bot, 'account': 1, 'channel_type': 'whatsapp', | ||
'bsp_type': 'meta', 'tabname': 'default', 'display_phone_number': '918657011111', | ||
'phone_number_id': '142427035629239'} | ||
assert whatsapp_msg_handler.call_args[0][4] == bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test function test_whatsapp_valid_flows_message_request
is well-structured and tests the WhatsApp integration effectively by simulating a POST request with a JSON payload that represents a WhatsApp message. The use of responses.activate
to mock HTTP responses is appropriate, and the assertions at the end of the test ensure that the expected outcome is achieved.
However, there are print statements within the test (lines 1651 and 1656) that should be removed as they are typically used for debugging and should not be present in the final test code.
- print(whatsapp_msg_handler.call_args[0][1])
- print(metadata)
Committable suggestion
❗ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
@responses.activate | |
def test_whatsapp_valid_flows_message_request(): | |
responses.reset() | |
def _mock_validate_hub_signature(*args, **kwargs): | |
return True | |
with patch.object(MessengerHandler, "validate_hub_signature", _mock_validate_hub_signature): | |
with mock.patch("kairon.chat.handlers.channels.whatsapp.Whatsapp._handle_user_message", | |
autospec=True) as whatsapp_msg_handler: | |
request_json = { | |
'object': 'whatsapp_business_account', | |
'entry': [{ | |
'id': '147142368486217', | |
'changes': [{ | |
'value': { | |
'messaging_product': 'whatsapp', | |
'metadata': { | |
'display_phone_number': '918657011111', | |
'phone_number_id': '142427035629239' | |
}, | |
'contacts': [{ | |
'profile': { | |
'name': 'Mahesh' | |
}, | |
'wa_id': '919515991111' | |
}], | |
'messages': [{ | |
'context': { | |
'from': '918657011111', | |
'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAERgSMjVGRjYwODI3RkMyOEQ0NUM1AA==' | |
}, | |
'from': '919515991111', | |
'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAEhggQTRBQUYyODNBQkMwNEIzRDQ0MUI1ODkyMTE2NTMA', | |
'timestamp': '1703257297', | |
'type': 'interactive', | |
'interactive': { | |
'type': 'nfm_reply', | |
'nfm_reply': { | |
'response_json': '{"flow_token":"AQBBBBBCS5FpgQ_cAAAAAD0QI3s.","firstName":"Mahesh ","lastName":"Sattala ","pincode":"523456","district":"Bangalore ","houseNumber":"5-6","dateOfBirth":"1703257240046","source":"SOCIAL_MEDIA","landmark":"HSR Layout ","email":"[email protected]"}', | |
'body': 'Sent', | |
'name': 'flow' | |
} | |
} | |
}] | |
}, | |
'field': 'messages' | |
}] | |
}] | |
} | |
response = client.post( | |
f"/api/bot/whatsapp/{bot}/{token}", | |
headers={"hub.verify_token": "valid"}, | |
json=request_json | |
) | |
actual = response.json() | |
assert actual == 'success' | |
assert len(whatsapp_msg_handler.call_args[0]) == 5 | |
print(whatsapp_msg_handler.call_args[0][1]) | |
assert whatsapp_msg_handler.call_args[0][1] == '/k_flow_msg{"nfm_reply": "{\\"flow_token\\":\\"AQBBBBBCS5FpgQ_cAAAAAD0QI3s.\\",\\"firstName\\":\\"Mahesh \\",\\"lastName\\":\\"Sattala \\",\\"pincode\\":\\"523456\\",\\"district\\":\\"Bangalore \\",\\"houseNumber\\":\\"5-6\\",\\"dateOfBirth\\":\\"1703257240046\\",\\"source\\":\\"SOCIAL_MEDIA\\",\\"landmark\\":\\"HSR Layout \\",\\"email\\":\\"[email protected]\\"}"}' | |
assert whatsapp_msg_handler.call_args[0][2] == '919515991111' | |
metadata = whatsapp_msg_handler.call_args[0][3] | |
metadata.pop("timestamp") | |
print(metadata) | |
assert metadata == { | |
'context': {'from': '918657011111', 'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAERgSMjVGRjYwODI3RkMyOEQ0NUM1AA=='}, | |
'from': '919515991111', 'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAEhggQTRBQUYyODNBQkMwNEIzRDQ0MUI1ODkyMTE2NTMA', | |
'type': 'interactive', | |
'interactive': { | |
'type': 'nfm_reply', 'nfm_reply': { | |
'response_json': '{"flow_token":"AQBBBBBCS5FpgQ_cAAAAAD0QI3s.","firstName":"Mahesh ","lastName":"Sattala ","pincode":"523456","district":"Bangalore ","houseNumber":"5-6","dateOfBirth":"1703257240046","source":"SOCIAL_MEDIA","landmark":"HSR Layout ","email":"[email protected]"}', | |
'body': 'Sent', 'name': 'flow'}}, | |
'is_integration_user': True, 'bot': bot, 'account': 1, 'channel_type': 'whatsapp', | |
'bsp_type': 'meta', 'tabname': 'default', 'display_phone_number': '918657011111', | |
'phone_number_id': '142427035629239'} | |
assert whatsapp_msg_handler.call_args[0][4] == bot | |
@responses.activate | |
def test_whatsapp_valid_flows_message_request(): | |
responses.reset() | |
def _mock_validate_hub_signature(*args, **kwargs): | |
return True | |
with patch.object(MessengerHandler, "validate_hub_signature", _mock_validate_hub_signature): | |
with mock.patch("kairon.chat.handlers.channels.whatsapp.Whatsapp._handle_user_message", | |
autospec=True) as whatsapp_msg_handler: | |
request_json = { | |
'object': 'whatsapp_business_account', | |
'entry': [{ | |
'id': '147142368486217', | |
'changes': [{ | |
'value': { | |
'messaging_product': 'whatsapp', | |
'metadata': { | |
'display_phone_number': '918657011111', | |
'phone_number_id': '142427035629239' | |
}, | |
'contacts': [{ | |
'profile': { | |
'name': 'Mahesh' | |
}, | |
'wa_id': '919515991111' | |
}], | |
'messages': [{ | |
'context': { | |
'from': '918657011111', | |
'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAERgSMjVGRjYwODI3RkMyOEQ0NUM1AA==' | |
}, | |
'from': '919515991111', | |
'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAEhggQTRBQUYyODNBQkMwNEIzRDQ0MUI1ODkyMTE2NTMA', | |
'timestamp': '1703257297', | |
'type': 'interactive', | |
'interactive': { | |
'type': 'nfm_reply', | |
'nfm_reply': { | |
'response_json': '{"flow_token":"AQBBBBBCS5FpgQ_cAAAAAD0QI3s.","firstName":"Mahesh ","lastName":"Sattala ","pincode":"523456","district":"Bangalore ","houseNumber":"5-6","dateOfBirth":"1703257240046","source":"SOCIAL_MEDIA","landmark":"HSR Layout ","email":"[email protected]"}', | |
'body': 'Sent', | |
'name': 'flow' | |
} | |
} | |
}] | |
}, | |
'field': 'messages' | |
}] | |
}] | |
} | |
response = client.post( | |
f"/api/bot/whatsapp/{bot}/{token}", | |
headers={"hub.verify_token": "valid"}, | |
json=request_json | |
) | |
actual = response.json() | |
assert actual == 'success' | |
assert len(whatsapp_msg_handler.call_args[0]) == 5 | |
assert whatsapp_msg_handler.call_args[0][1] == '/k_flow_msg{"nfm_reply": "{\\"flow_token\\":\\"AQBBBBBCS5FpgQ_cAAAAAD0QI3s.\\",\\"firstName\\":\\"Mahesh \\",\\"lastName\\":\\"Sattala \\",\\"pincode\\":\\"523456\\",\\"district\\":\\"Bangalore \\",\\"houseNumber\\":\\"5-6\\",\\"dateOfBirth\\":\\"1703257240046\\",\\"source\\":\\"SOCIAL_MEDIA\\",\\"landmark\\":\\"HSR Layout \\",\\"email\\":\\"[email protected]\\"}"}' | |
assert whatsapp_msg_handler.call_args[0][2] == '919515991111' | |
metadata = whatsapp_msg_handler.call_args[0][3] | |
metadata.pop("timestamp") | |
assert metadata == { | |
'context': {'from': '918657011111', 'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAERgSMjVGRjYwODI3RkMyOEQ0NUM1AA=='}, | |
'from': '919515991111', 'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAEhggQTRBQUYyODNBQkMwNEIzRDQ0MUI1ODkyMTE2NTMA', | |
'type': 'interactive', | |
'interactive': { | |
'type': 'nfm_reply', 'nfm_reply': { | |
'response_json': '{"flow_token":"AQBBBBBCS5FpgQ_cAAAAAD0QI3s.","firstName":"Mahesh ","lastName":"Sattala ","pincode":"523456","district":"Bangalore ","houseNumber":"5-6","dateOfBirth":"1703257240046","source":"SOCIAL_MEDIA","landmark":"HSR Layout ","email":"[email protected]"}', | |
'body': 'Sent', 'name': 'flow'}}, | |
'is_integration_user': True, 'bot': bot, 'account': 1, 'channel_type': 'whatsapp', | |
'bsp_type': 'meta', 'tabname': 'default', 'display_phone_number': '918657011111', | |
'phone_number_id': '142427035629239'} | |
assert whatsapp_msg_handler.call_args[0][4] == bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files selected for processing (2)
- kairon/chat/handlers/channels/whatsapp.py (1 hunks)
- tests/integration_test/chat_service_test.py (1 hunks)
Additional comments: 2
kairon/chat/handlers/channels/whatsapp.py (1)
- 43-49: The new logic for handling "nfm_reply" interactive messages seems to correctly construct a formatted response. However, ensure that the
response_json
variable is properly formatted and that thetext
variable is assigned the correct string format for the response.tests/integration_test/chat_service_test.py (1)
- 1594-1668: The test function
test_whatsapp_valid_flows_message_request
is designed to simulate a WhatsApp message request with a "nfm_reply" type and verify the handling logic. Ensure that the test covers all necessary assertions and correctly mocks external dependencies.
response = client.post( | ||
f"/api/bot/whatsapp/{bot}/{token}", | ||
headers={"hub.verify_token": "valid"}, | ||
json=request_json | ||
) | ||
actual = response.json() | ||
assert actual == 'success' | ||
assert len(whatsapp_msg_handler.call_args[0]) == 5 | ||
assert whatsapp_msg_handler.call_args[0][1] == '/k_flow_msg{\"nfm_reply\": {\"flow_token\": \"AQBBBBBCS5FpgQ_cAAAAAD0QI3s.\", \"firstName\": \"Mahesh \", \"lastName\": \"Sattala \", \"pincode\": \"523456\", \"district\": \"Bangalore \", \"houseNumber\": \"5-6\", \"dateOfBirth\": \"1703257240046\", \"source\": \"SOCIAL_MEDIA\", \"landmark\": \"HSR Layout \", \"email\": \"[email protected]\"}}' | ||
assert whatsapp_msg_handler.call_args[0][2] == '919515991111' | ||
metadata = whatsapp_msg_handler.call_args[0][3] | ||
metadata.pop("timestamp") | ||
assert metadata == { | ||
'context': {'from': '918657011111', 'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAERgSMjVGRjYwODI3RkMyOEQ0NUM1AA=='}, | ||
'from': '919515991111', 'id': 'wamid.HBgMOTE5NTE1OTkxNjg1FQIAEhggQTRBQUYyODNBQkMwNEIzRDQ0MUI1ODkyMTE2NTMA', | ||
'type': 'interactive', | ||
'interactive': { | ||
'type': 'nfm_reply', 'nfm_reply': { | ||
'response_json': '{"flow_token":"AQBBBBBCS5FpgQ_cAAAAAD0QI3s.","firstName":"Mahesh ","lastName":"Sattala ","pincode":"523456","district":"Bangalore ","houseNumber":"5-6","dateOfBirth":"1703257240046","source":"SOCIAL_MEDIA","landmark":"HSR Layout ","email":"[email protected]"}', | ||
'body': 'Sent', 'name': 'flow'}}, | ||
'is_integration_user': True, 'bot': bot, 'account': 1, 'channel_type': 'whatsapp', | ||
'bsp_type': 'meta', 'tabname': 'default', 'display_phone_number': '918657011111', | ||
'phone_number_id': '142427035629239'} | ||
assert whatsapp_msg_handler.call_args[0][4] == bot | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test function test_whatsapp_valid_flows_message_request
should include assertions to verify the expected behavior and outcome after the simulated WhatsApp message request is processed.
Consider verifying if any cleanup or teardown steps are required after the test execution to maintain test isolation and prevent side effects on subsequent tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (2)
- kairon/chat/handlers/channels/whatsapp.py (1 hunks)
- tests/integration_test/chat_service_test.py (1 hunks)
Additional comments: 2
tests/integration_test/chat_service_test.py (2)
1594-1668: The new test function
test_whatsapp_valid_flows_message_request
is added to validate the handling of WhatsApp messages with "nfm_reply" type. The test simulates a WhatsApp message request and checks the response. The test seems to be correctly structured and follows the pattern of other existing tests in the file. It uses theresponses
library to mock HTTP responses, which is consistent with the rest of the test suite.1591-1672: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [1-1668]
Overall, the file contains a comprehensive set of integration tests for the chat service. The tests cover various scenarios, including different message types and error handling. The use of mocking and patching is consistent and appropriate for the context of the tests. The tests are well-structured and seem to follow best practices for testing asynchronous code and external service interactions.
if interactive_type == "nfm_reply": | ||
logger.debug(message["interactive"][interactive_type]) | ||
response_json = json.loads(message["interactive"][interactive_type]['response_json']) | ||
response_json.update({"type": interactive_type}) | ||
entity = json.dumps({interactive_type: response_json}) | ||
text = f"/k_interactive_msg{entity}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new logic for handling "nfm_reply" interactive messages seems to correctly parse the JSON data and construct the text
response. However, it's important to ensure that the response_json
is always in the expected format and that the json.loads
call does not fail due to malformed JSON. It would be prudent to add error handling around the JSON parsing to gracefully handle any potential issues.
+ try:
+ response_json = json.loads(message["interactive"][interactive_type]['response_json'])
+ except json.JSONDecodeError as e:
+ logger.error(f"Failed to parse 'response_json': {e}")
+ # Handle the error appropriately, possibly with a default response or notification
Committable suggestion
❗ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
if interactive_type == "nfm_reply": | |
logger.debug(message["interactive"][interactive_type]) | |
response_json = json.loads(message["interactive"][interactive_type]['response_json']) | |
response_json.update({"type": interactive_type}) | |
entity = json.dumps({interactive_type: response_json}) | |
text = f"/k_interactive_msg{entity}" | |
if interactive_type == "nfm_reply": | |
logger.debug(message["interactive"][interactive_type]) | |
try: | |
response_json = json.loads(message["interactive"][interactive_type]['response_json']) | |
except json.JSONDecodeError as e: | |
logger.error(f"Failed to parse 'response_json': {e}") | |
# Handle the error appropriately, possibly with a default response or notification | |
response_json.update({"type": interactive_type}) | |
entity = json.dumps({interactive_type: response_json}) | |
text = f"/k_interactive_msg{entity}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (4)
- kairon/chat/handlers/channels/whatsapp.py (1 hunks)
- kairon/shared/constants.py (1 hunks)
- tests/integration_test/chat_service_test.py (1 hunks)
- tests/integration_test/services_test.py (3 hunks)
Files skipped from review due to trivial changes (1)
- kairon/shared/constants.py
Files skipped from review as they are similar to previous changes (2)
- kairon/chat/handlers/channels/whatsapp.py
- tests/integration_test/chat_service_test.py
Additional comments: 3
tests/integration_test/services_test.py (3)
2914-2914: The expected length of the
actual['data']
array has been increased. This change should correspond to the addition of new data elements due to the PR changes. Ensure that the increment in the array length is consistent with the new features added.3039-3040: A new element,
'flow_reply'
, has been added to the set of expected names. This should correspond to the new constant added to theKaironSystemSlots
enum class as mentioned in the PR objectives. Confirm that this new element is indeed part of the changes and is expected in the test response.Verification successful
Let's correct the script to search for the 'flow_reply' within the
KaironSystemSlots
enum class without specifying the file type. We will userg
to search for the term 'flow_reply' and then check the surrounding context to confirm it is part of theKaironSystemSlots
enum.
The shell script has successfully identified the presence of
flow_reply
within theKaironSystemSlots
enum class in thekairon/shared/constants.py
file. This confirms that the addition of'flow_reply'
to the set of expected names in the test response is indeed part of the changes made in the PR and is expected in the test response as per the review comment.* 3441-3441: The expected length of the `actual["data"]` array has been increased. Similar to the first hunk, this should be due to the addition of new data elements related to the PR changes. Confirm that the increment is justified by the new features.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that 'flow_reply' is a new addition to the expected names in the test response and is related to the changes made in the PR. rg --type python 'KaironSystemSlots' -A 10 | grep 'flow_reply'Length of output: 91
Script:
#!/bin/bash # Search for 'flow_reply' within the context of the KaironSystemSlots enum class. rg 'KaironSystemSlots' -A 10 | grep 'flow_reply'Length of output: 103
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- tests/unit_test/data_processor/data_processor_test.py (20 hunks)
Additional comments: 20
tests/unit_test/data_processor/data_processor_test.py (20)
1038-1038: The change in the number of slots with
influence_conversation=True
from the previous value to 8 needs to be justified. Is there a new slot added or an existing slot modified that influences the conversation?1458-1458: The addition of
'flow_reply'
to the list of slot names in the domain should be cross-checked with the implementation to ensure that this slot is indeed intended to be part of the domain.1566-1567: The increase in the number of slots and the specific count of slots influencing the conversation should be verified against the domain model changes to ensure consistency.
1639-1639: The decrease in the number of slots needs to be verified to ensure that it aligns with the intended domain model changes.
1685-1685: The assertion for the number of slots and templates should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
1713-1713: The assertion for the number of slots and entities should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
1963-1963: The assertion for the number of slots and the specific slot 'priority' should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
1996-1996: The assertion for the number of slots and the specific slot 'ticketid' should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
2039-2039: The assertion for the number of entities should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
4693-4693: The assertion for the number of slots, intent properties, and user actions should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
4759-4759: The assertion for the number of slots, entities, and user actions should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
4814-4814: The assertion for the number of slots, intent properties, and user actions should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
4877-4877: The assertion for the number of slots, intent properties, and user actions should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
4927-4927: The assertion for the number of slots, intent properties, and user actions should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
4984-4984: The assertion for the number of slots, intent properties, and user actions should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
5029-5029: The assertion for the number of slots, intent properties, and user actions should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
5083-5083: The assertion for the number of slots, intent properties, and user actions should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
5159-5159: The assertion for the number of slots, intent properties, and user actions should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
6844-6844: The assertion for the number of slots should be verified to ensure that the domain model is correctly reflecting the expected state after the changes.
6862-6863: The addition of the 'flow_reply' slot should be verified to ensure that it is correctly configured and intended to be part of the domain model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved
Added code to Get whatsapp flow details from webhook.
Summary by CodeRabbit
New Features
Tests