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

feat: Use external service for triggers #31268

Merged
merged 71 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
614d90f
BE for triggers
KevLehman Dec 18, 2023
7670152
public endpoint for calling
KevLehman Jan 2, 2024
90b8540
ts
KevLehman Jan 3, 2024
ffa599b
fix: trigger's form information not being filled properly
aleksandernsilva Dec 26, 2023
4e6f3fc
refactor: streamlined trigger flow
aleksandernsilva Dec 26, 2023
d2d519c
feat: added initial external service action
aleksandernsilva Dec 28, 2023
9f74858
feat: refactored and added new external service action to admin
aleksandernsilva Jan 8, 2024
a52718c
feat: implemented external service action to the widget
aleksandernsilva Jan 8, 2024
0b8be33
webhook
KevLehman Jan 10, 2024
4eabefe
chore: removed webhook from trigger endpoint error code
aleksandernsilva Jan 11, 2024
cbb139a
feat: implemented hook useFieldError
aleksandernsilva Jan 11, 2024
ce03dce
feat: added external service test and many other form adjustments
aleksandernsilva Jan 11, 2024
fac7937
chore: removed logs
aleksandernsilva Jan 11, 2024
9f0c7d7
chore: form adjustments
aleksandernsilva Jan 11, 2024
a018e17
fix: form validation and removed a infinite loop
aleksandernsilva Jan 12, 2024
eaa544b
chore: added expressions in pt-BR
aleksandernsilva Jan 12, 2024
dfeffb6
feat: added setGuestMetadata method to the Livechat API
aleksandernsilva Jan 12, 2024
361b856
chore: added missing pt-BR expression
aleksandernsilva Jan 12, 2024
5424751
chore: converted files to ts
aleksandernsilva Jan 12, 2024
152e412
fix: changed default action to send-message
aleksandernsilva Jan 12, 2024
ac9ea9b
feat: added success feedback for external service test
aleksandernsilva Jan 12, 2024
b2d0bfa
default timeout
KevLehman Jan 12, 2024
e8cf47f
Merge branch 'develop' into feat/triggers-omni
KevLehman Jan 15, 2024
4ddea80
test
KevLehman Jan 15, 2024
8f4a499
Merge branch 'develop' into feat/triggers-omni
KevLehman Jan 15, 2024
daa8f3c
Merge branch 'feat/triggers-omni' of github.com:RocketChat/Rocket.Cha…
KevLehman Jan 15, 2024
7830d19
remove file
KevLehman Jan 15, 2024
8aa312b
cmon
KevLehman Jan 15, 2024
eedfd8a
fix be tests
KevLehman Jan 15, 2024
e27f45c
Merge branch 'develop' into feat/triggers-omni
KevLehman Jan 18, 2024
8542f4a
wip: prep work for component
MartinSchoeler Jan 19, 2024
f3107f5
Merge branch 'develop' into feat/triggers-omni
KevLehman Jan 22, 2024
5d5ce80
triggers to ee
KevLehman Jan 22, 2024
ed890aa
missing import
KevLehman Jan 22, 2024
d6d235a
send premiumCapabilities flag to widget
KevLehman Jan 22, 2024
ab30c11
EE select
MartinSchoeler Jan 22, 2024
f4c3f6d
ee
MartinSchoeler Jan 26, 2024
bc955d1
fix QA findings
MartinSchoeler Jan 29, 2024
8d32b1d
Merge remote-tracking branch 'origin/develop' into feat/triggers-omni
MartinSchoeler Jan 29, 2024
af98006
chore: removed FormContext and renamed useFormAction hook
aleksandernsilva Jan 30, 2024
a80bc30
chore: minor adjustments
aleksandernsilva Jan 30, 2024
7085cde
feat: changed service success message to be displayed within the button
aleksandernsilva Jan 30, 2024
9211a7b
fix: missing field id
aleksandernsilva Jan 31, 2024
0cad7b8
chore: adjusted triggers e2e tests
aleksandernsilva Jan 31, 2024
28db538
feat: added method to clean up triggers records
aleksandernsilva Jan 31, 2024
d8cf3f4
chore: changing to make use of required on FieldLabel
aleksandernsilva Feb 2, 2024
256da94
chore: type adjustments
aleksandernsilva Feb 5, 2024
1982330
fix: condition not being sent to action
aleksandernsilva Feb 5, 2024
e81bc01
test: cleanup test setting
MarcosSpessatto Feb 9, 2024
2e7e51e
fix: multiple time-on-site conditions causing conflict
aleksandernsilva Feb 12, 2024
2f5bc37
fix: all triggers fail to fire when an error happens
aleksandernsilva Feb 20, 2024
372811d
fix: added missing await
aleksandernsilva Feb 20, 2024
ac30ef3
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into feat…
aleksandernsilva Feb 20, 2024
ad0a7ec
fix: Allow only numbers, if trigger's condition is 'visitor time on s…
aleksandernsilva Feb 20, 2024
add0574
chore: changeset
aleksandernsilva Feb 20, 2024
9991d2e
fix: restored agent cache and added fallback custom agent
aleksandernsilva Feb 23, 2024
06edd2d
refactor: changed useActionFormFields hook to an util fn
aleksandernsilva Feb 23, 2024
8670c0b
refactor: create an index file for trigger hooks
aleksandernsilva Feb 23, 2024
8023bd4
refactor: simplified color use and added useSafely
aleksandernsilva Feb 23, 2024
900d6e8
chore: removed unnused import
aleksandernsilva Feb 26, 2024
a3feed1
fix: filter out premium triggers when no license is found
aleksandernsilva Feb 26, 2024
e5a45cf
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into feat…
aleksandernsilva Feb 28, 2024
baae864
chore: changeset
aleksandernsilva Feb 28, 2024
197eb8b
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into feat…
aleksandernsilva Mar 5, 2024
6c772a4
refactor: moved guest metadata to its own property
aleksandernsilva Mar 5, 2024
4b2f73b
fix: restored assign agent
aleksandernsilva Mar 5, 2024
16f891b
refactor: changed to not depend on endpoint for fallback message
aleksandernsilva Mar 6, 2024
7336bc7
fix: increased rate limiter to 10 requests/sec
aleksandernsilva Mar 6, 2024
1074224
fix: increased rate limiter for test endpoint to 15 requests/sec
aleksandernsilva Mar 6, 2024
7659cfa
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into feat…
aleksandernsilva Mar 12, 2024
13967a7
Merge branch 'develop' into feat/triggers-omni
kodiakhq[bot] Mar 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/rich-rocks-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@rocket.chat/meteor': minor
'@rocket.chat/core-typings': minor
'@rocket.chat/livechat': minor
---

Added new Livechat trigger action "Send message (external service)"
18 changes: 12 additions & 6 deletions apps/meteor/app/livechat/server/api/lib/livechat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
IOmnichannelRoom,
SelectedAgent,
} from '@rocket.chat/core-typings';
import { License } from '@rocket.chat/license';
import { EmojiCustom, LivechatTrigger, LivechatVisitors, LivechatRooms, LivechatDepartment } from '@rocket.chat/models';
import { Random } from '@rocket.chat/random';
import { Meteor } from 'meteor/meteor';
Expand All @@ -21,12 +22,17 @@ export function online(department: string, skipSettingCheck = false, skipFallbac

async function findTriggers(): Promise<Pick<ILivechatTrigger, '_id' | 'actions' | 'conditions' | 'runOnce'>[]> {
const triggers = await LivechatTrigger.findEnabled().toArray();
return triggers.map(({ _id, actions, conditions, runOnce }) => ({
_id,
actions,
conditions,
runOnce,
}));
const hasLicense = License.hasModule('livechat-enterprise');
const premiumActions = ['use-external-service'];

return triggers
.filter(({ actions }) => hasLicense || actions.some((c) => !premiumActions.includes(c.name)))
.map(({ _id, actions, conditions, runOnce }) => ({
_id,
actions,
conditions,
runOnce,
}));
}

async function findDepartments(
Expand Down
74 changes: 74 additions & 0 deletions apps/meteor/client/views/omnichannel/triggers/ConditionForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import type { SelectOption } from '@rocket.chat/fuselage';
import { Field, FieldGroup, FieldLabel, FieldRow, NumberInput, Select, TextInput } from '@rocket.chat/fuselage';
import { useUniqueId } from '@rocket.chat/fuselage-hooks';
import { useTranslation } from '@rocket.chat/ui-contexts';
import type { ComponentProps } from 'react';
import React, { useMemo } from 'react';
import type { Control } from 'react-hook-form';
import { Controller, useWatch } from 'react-hook-form';

import type { TriggersPayload } from './EditTrigger';

type ConditionFormType = ComponentProps<typeof Field> & {
index: number;
control: Control<TriggersPayload>;
};

export const ConditionForm = ({ control, index, ...props }: ConditionFormType) => {
const conditionFieldId = useUniqueId();
const t = useTranslation();
const conditionName = useWatch({ control, name: `conditions.${index}.name` });

const placeholders: { [conditionName: string]: string } = useMemo(
() => ({
'page-url': t('Enter_a_regex'),
'time-on-site': t('Time_in_seconds'),
}),
[t],
);

const conditionOptions: SelectOption[] = useMemo(
() => [
['page-url', t('Visitor_page_URL')],
['time-on-site', t('Visitor_time_on_site')],
['chat-opened-by-visitor', t('Chat_opened_by_visitor')],
['after-guest-registration', t('After_guest_registration')],
],
[t],
);

const conditionValuePlaceholder = placeholders[conditionName];

return (
<FieldGroup {...props}>
<Field>
<FieldLabel htmlFor={conditionFieldId}>{t('Condition')}</FieldLabel>
<FieldRow>
<Controller
name={`conditions.${index}.name`}
control={control}
render={({ field }) => (
<Select {...field} id={conditionFieldId} options={conditionOptions} placeholder={t('Select_an_option')} />
)}
/>
</FieldRow>

{conditionValuePlaceholder && (
<FieldRow>
<Controller
name={`conditions.${index}.value`}
control={control}
render={({ field }) => {
if (conditionName === 'time-on-site') {
return <NumberInput {...field} placeholder={conditionValuePlaceholder} />;
}

return <TextInput {...field} placeholder={conditionValuePlaceholder} />;
}}
/>
</FieldRow>
)}
</Field>
</FieldGroup>
);
};
Loading
Loading