Skip to content
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

Merged
merged 5 commits into from
Jan 8, 2024
Merged

Conversation

maheshsattala
Copy link
Contributor

@maheshsattala maheshsattala commented Jan 5, 2024

Added code to Get whatsapp flow details from webhook.

Summary by CodeRabbit

  • New Features

    • Introduced support for a new interactive message type "nfm_reply" in WhatsApp chat integration.
  • Tests

    • Added integration tests for verifying WhatsApp message flows and response handling.

Copy link

coderabbitai bot commented Jan 5, 2024

Walkthrough

Walkthrough

The 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

File Path Change Summary
kairon/chat/handlers/channels/whatsapp.py Modified logic for handling "nfm_reply" interactive messages, involving parsing and updating JSON data for constructing the response.
kairon/shared/constants.py Added a new constant flow_reply to the KaironSystemSlots enum class.
tests/integration_test/chat_service_test.py Added a new test function test_whatsapp_valid_flows_message_request to simulate a WhatsApp message request and check the response.
tests/integration_test/services_test.py Adjusted expected lengths of data arrays in test responses and added a new element to a set of expected names.

Poem

🐰 Hopping through the code with glee,
A new message type we now can see.
Tests ensure our flow's watertight,
CodeRabbit's work shines oh so bright. 🌟

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?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 6a6540f and 83af06c.
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 using json.dumps seems correct, but it's important to ensure that the message["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.

Comment on lines 1594 to 1668
@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
Copy link

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.

Suggested change
@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

Copy link

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 83af06c and 8533ea7.
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 the text 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.

Comment on lines 1644 to 1668
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

Copy link

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.

Copy link

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 8533ea7 and 397b624.
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 the responses 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.

Comment on lines 43 to 48
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}"
Copy link

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.

Suggested change
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}"

Copy link

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 397b624 and 2eda8aa.
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 the KaironSystemSlots 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 use rg to search for the term 'flow_reply' and then check the surrounding context to confirm it is part of the KaironSystemSlots enum.


The shell script has successfully identified the presence of flow_reply within the KaironSystemSlots enum class in the kairon/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.

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

* 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.

Copy link

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 2eda8aa and 39534b3.
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.

Copy link
Contributor

@udit-pandey udit-pandey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved

@udit-pandey udit-pandey merged commit 695d084 into digiteinfotech:master Jan 8, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants