Skip to content

Conversation

@cauefcr
Copy link
Contributor

@cauefcr cauefcr commented Jul 7, 2022

Proposed changes (including videos or screenshots)

Users of the endpoints api/v1/omnichannel/contact.search and /api/v1/livechat/visitors.search are now able to search by custom fields in their objects.
Capability of selecting if a custom field can be searched for is added in the Omnichannel pannel as a toggle for searchable, the included JSON in the Accounts' Custom Field example has been updated to make it explicit for future configurations that the field has to be enabled as searchable for that to happen.

Issue(s)

Steps to test or reproduce

Create a new custom field on Omnichannel->custom field, selecting it as searchable.
Edit a LiveChat visitor conversation to include custom field created above.
On the contact center, you can now search for the contents of that custom field.

Further comments

This branch is broken, here is the new one

@cauefcr cauefcr requested a review from a team as a code owner July 7, 2022 18:05
@cauefcr cauefcr changed the title [IMPROVE] Capability to search users and visitors by custom fields [IMPROVE] Capability to search visitors by custom fields Jul 7, 2022
@cauefcr cauefcr requested a review from a team July 13, 2022 15:02
Copy link
Member

@KevLehman KevLehman left a comment

Choose a reason for hiding this comment

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

There's also some "custom fields" specially made for livechat that i don't see here 👀 (endpoints) could you pls check that? Thanks!

const allowedCF = LivechatCustomField.find({ scope: 'visitor' }, { fields: { _id: 1 } }, { searchability: true }).map(
({ _id }) => _id,
);
const customObj = Object.fromEntries(Array.from(new URLSearchParams(custom)).filter(([k]) => allowedCF.includes(k)));
Copy link
Member

Choose a reason for hiding this comment

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

Can you share an example of what custom would look like? Wanna see why we need to manually parsing the searchparams 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, we can make one with new URLSearchParams({field:1,other:"string"}).toString(), for example, that leads to field=1&other=string, and the quoted line way to get the object to put on the query.

Copy link
Member

Choose a reason for hiding this comment

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

No but, how will that key look like? 👀 cause from what you have seems custom will be something like custom=a=1&b=1 which I'm not sure how url safe would be 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it gets URL encoded, so it's end up as custom=a%3D1%26b%3D1, very ugly but works.


return preserveHtml ? html : html && sanitizer(html, { ADD_ATTR: ['target'] });
}, [content, preserveHtml, sanitizer, markedOptions, parseEmoji]);
}, [content, preserveHtml, sanitizer, markedOptions, parseEmoji, variant]);
Copy link
Member

Choose a reason for hiding this comment

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

🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

typescript complained that it was being used without being depended on

Copy link
Member

Choose a reason for hiding this comment

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

Weird, if it's not affecting the pipeline, leave this one out of the PR and notify alek/tiago so they can look at it. (I haven't got this issue, so could have been removed intentional 👀 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it does affect the CI, breaking on eslintreact-hooks/exhaustive-deps

Copy link
Member

Choose a reason for hiding this comment

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

No but, can you try updating with latest of develop? I'm curious why this is not failing on any other place 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@cauefcr cauefcr requested a review from a team as a code owner July 13, 2022 20:38
@renatobecker renatobecker added this to the 5.1.0 milestone Jul 14, 2022
cauefcr and others added 2 commits July 19, 2022 17:39
Co-authored-by: Kevin Aleman <kaleman960@gmail.com>
@cauefcr cauefcr closed this Jul 20, 2022
@tassoevan tassoevan deleted the new/custom-field-search branch September 27, 2022 22:23
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.

5 participants