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

CHI-3069: Backend contact create #730

Merged
merged 18 commits into from
Dec 19, 2024
Merged

Conversation

stephenhand
Copy link
Collaborator

@stephenhand stephenhand commented Dec 12, 2024

Description

  • Adds an additional handler to create new contacts when a reservation is accepted, except in the case of offline contact tasks, or tasks created to receive chat transfers
  • Loads the form definitions and prepopulates the new contact with data from the task
  • Adds the contact ID of the new contact to the task attributes, so the client is aware that the contact has been provided
  • All behind an enable_backend_hrm_contact_creation feature flag.

We are currently only using the static key encryption on the HRM call. We'll probably need something more secure for production

Checklist

  • Corresponding issue has been opened
  • New tests added
  • Feature flags / configuration added

Other Related Issues

None

Verification steps

Regression test new call & chat contacts, transfers and offline contacts

AFTER YOU MERGE

  1. Cut a release tag using the GitHub workflow. Wait for it to complete and the notification to be posted in the #aselo-deploys Slack channel.
  2. Comment on the ticket with the release tag version AND any additional instructions required to configure an environment to test the changes.
  3. Only then move the ticket into the QA column in JIRA

You are responsible for ensuring the above steps are completed. If you move a ticket into QA without advising what version to test, the QA team will assume the latest tag has the changes. If it does not, the following confusion is on you! :-P

@stephenhand stephenhand changed the title CHI=3069: Backend contact create CHI-3069: Backend contact create Dec 12, 2024
Copy link
Collaborator

@GPaoloni GPaoloni left a comment

Choose a reason for hiding this comment

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

LGTM as far as I can tell

const adjustChatCapacity: AdjustChatCapacityType = require(path).adjustChatCapacity;
const body = {
workerSid,
adjustment: 'setTo1',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to set capacity to 1 here? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We always set it back to 1 on certain events. With backend manual pulling, instead of trying to track capacity, we just always have it set to 1, them set it to the value required to take an extra task when manually pulling or accepting transfers, then set it back to 1 again when we're done.

There is no issue with being 'over capacity' other than not being able to accept more tasks, so this is simpler than trying to track capacity against tasks

Also this logic isn't changed in this PR

return false;
}

if (transferTargetType) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this could reuse the hasTransferStarted method (functions/transfer/helpers.private.ts)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not worth pulling it in for IMHO, when it's a lambda and we can import stuff properly then sure


const prepopulatePath = Runtime.getFunctions()['hrm/prepopulateForm'].path;
const { prepopulateForm } = require(prepopulatePath) as PrepopulateForm;
await prepopulateForm(taskAttributes, contactForApi, formDefinitionsVersionUrl);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think is harder to follow what is really happening here, cause prepopulateForm is mutating the given contact. Could we return a new object to make this explicit? (I will really appreciate that information being evident next time I'm around this code 😛)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I won't make it a pure function because that makes it significantly uglier for deep objects and there's no practical benefit here since it's a brand new contact anyway.

I thought using 'populate' in the method name would have made the mutation effect clear, bad assumption on my part.

So the function still mutates but we reassign the output to a new variable to be clear. I also changed the method name to be more descriptive

Copy link
Collaborator

Choose a reason for hiding this comment

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

The reassignment is good enough, I don't mind it being pure as much as being explicit that the contact was transformed. Thanks for the change!

@stephenhand stephenhand merged commit b62d9c0 into master Dec 19, 2024
4 checks passed
@stephenhand stephenhand deleted the CHI-3069-backend_contact_create branch December 19, 2024 09:13
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