@nyaruka/temba-components 0.129.10 → 0.129.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/demo/data/flows/sample-flow.json +96 -56
- package/dist/temba-components.js +278 -268
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/events.js.map +1 -1
- package/out-tsc/src/flow/Editor.js +9 -6
- package/out-tsc/src/flow/Editor.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_channel.js +1 -1
- package/out-tsc/src/flow/actions/set_contact_channel.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_field.js +1 -1
- package/out-tsc/src/flow/actions/set_contact_field.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_language.js +1 -1
- package/out-tsc/src/flow/actions/set_contact_language.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_status.js +1 -1
- package/out-tsc/src/flow/actions/set_contact_status.js.map +1 -1
- package/out-tsc/src/flow/config.js +2 -8
- package/out-tsc/src/flow/config.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_llm.js +101 -0
- package/out-tsc/src/flow/nodes/split_by_llm.js.map +1 -0
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js +4 -89
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_subflow.js +123 -3
- package/out-tsc/src/flow/nodes/split_by_subflow.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_ticket.js +115 -13
- package/out-tsc/src/flow/nodes/split_by_ticket.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_webhook.js +160 -12
- package/out-tsc/src/flow/nodes/split_by_webhook.js.map +1 -1
- package/out-tsc/src/live/ContactChat.js +48 -66
- package/out-tsc/src/live/ContactChat.js.map +1 -1
- package/out-tsc/src/utils.js +115 -0
- package/out-tsc/src/utils.js.map +1 -1
- package/out-tsc/test/nodes/split_by_llm.test.js +174 -0
- package/out-tsc/test/nodes/split_by_llm.test.js.map +1 -0
- package/package.json +1 -1
- package/screenshots/truth/actions/add_contact_groups/editor/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/call_llm/editor/information-extraction.png +0 -0
- package/screenshots/truth/actions/call_llm/editor/sentiment-analysis.png +0 -0
- package/screenshots/truth/actions/call_llm/editor/summarization.png +0 -0
- package/screenshots/truth/actions/call_llm/editor/translation-task.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/editor/single-group.png +0 -0
- package/screenshots/truth/actions/send_email/editor/complex-business-email.png +0 -0
- package/screenshots/truth/actions/send_email/editor/empty-body.png +0 -0
- package/screenshots/truth/actions/send_email/editor/empty-subject.png +0 -0
- package/screenshots/truth/actions/send_email/editor/long-subject.png +0 -0
- package/screenshots/truth/actions/send_email/editor/multiline-body.png +0 -0
- package/screenshots/truth/actions/send_email/editor/multiple-recipients.png +0 -0
- package/screenshots/truth/actions/send_email/editor/simple-email.png +0 -0
- package/screenshots/truth/actions/send_email/editor/with-expressions.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/long-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/multiline-text-with-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/simple-text.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-linebreaks.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-many-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-with-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/editor/text-without-quick-replies.png +0 -0
- package/screenshots/truth/checkbox/checkbox-label-background-hover.png +0 -0
- package/screenshots/truth/checkbox/checkbox-no-label-no-background-hover.png +0 -0
- package/screenshots/truth/checkbox/checkbox-whitespace-label-no-background-hover.png +0 -0
- package/screenshots/truth/checkbox/checkbox-with-help-text.png +0 -0
- package/screenshots/truth/checkbox/checked.png +0 -0
- package/screenshots/truth/checkbox/default.png +0 -0
- package/screenshots/truth/colorpicker/default.png +0 -0
- package/screenshots/truth/colorpicker/focused.png +0 -0
- package/screenshots/truth/colorpicker/initialized.png +0 -0
- package/screenshots/truth/colorpicker/selected.png +0 -0
- package/screenshots/truth/compose/attachments-tab.png +0 -0
- package/screenshots/truth/compose/attachments-with-files.png +0 -0
- package/screenshots/truth/compose/intial-text.png +0 -0
- package/screenshots/truth/compose/no-counter.png +0 -0
- package/screenshots/truth/compose/wraps-text-and-spaces.png +0 -0
- package/screenshots/truth/compose/wraps-text-and-url.png +0 -0
- package/screenshots/truth/compose/wraps-text-no-spaces.png +0 -0
- package/screenshots/truth/contacts/chat-failure.png +0 -0
- package/screenshots/truth/contacts/chat-for-active-contact.png +0 -0
- package/screenshots/truth/contacts/chat-sends-attachments-only.png +0 -0
- package/screenshots/truth/contacts/chat-sends-text-and-attachments.png +0 -0
- package/screenshots/truth/contacts/chat-sends-text-only.png +0 -0
- package/screenshots/truth/counter/summary.png +0 -0
- package/screenshots/truth/counter/text.png +0 -0
- package/screenshots/truth/counter/unicode-variables.png +0 -0
- package/screenshots/truth/counter/unicode.png +0 -0
- package/screenshots/truth/counter/variable.png +0 -0
- package/screenshots/truth/datepicker/date-truncated-time.png +0 -0
- package/screenshots/truth/datepicker/date.png +0 -0
- package/screenshots/truth/datepicker/initial-timezone.png +0 -0
- package/screenshots/truth/datepicker/range-picker-editing-start.png +0 -0
- package/screenshots/truth/datepicker/updated-keyboard-date.png +0 -0
- package/screenshots/truth/dialog/focused.png +0 -0
- package/screenshots/truth/dropdown/right-edge-collision.png +0 -0
- package/screenshots/truth/editor/router.png +0 -0
- package/screenshots/truth/editor/send_msg.png +0 -0
- package/screenshots/truth/editor/set_contact_language.png +0 -0
- package/screenshots/truth/editor/set_contact_name.png +0 -0
- package/screenshots/truth/editor/set_run_result.png +0 -0
- package/screenshots/truth/editor/wait.png +0 -0
- package/screenshots/truth/field-renderer/checkbox-checked.png +0 -0
- package/screenshots/truth/field-renderer/checkbox-unchecked.png +0 -0
- package/screenshots/truth/field-renderer/checkbox-with-errors.png +0 -0
- package/screenshots/truth/field-renderer/context-comparison.png +0 -0
- package/screenshots/truth/field-renderer/key-value-with-label.png +0 -0
- package/screenshots/truth/field-renderer/message-editor-with-label.png +0 -0
- package/screenshots/truth/field-renderer/select-multi.png +0 -0
- package/screenshots/truth/field-renderer/select-no-label.png +0 -0
- package/screenshots/truth/field-renderer/select-with-label.png +0 -0
- package/screenshots/truth/field-renderer/text-evaluated.png +0 -0
- package/screenshots/truth/field-renderer/text-no-label.png +0 -0
- package/screenshots/truth/field-renderer/text-with-errors.png +0 -0
- package/screenshots/truth/field-renderer/text-with-label.png +0 -0
- package/screenshots/truth/field-renderer/textarea-evaluated.png +0 -0
- package/screenshots/truth/field-renderer/textarea-with-label.png +0 -0
- package/screenshots/truth/integration/checkbox-markdown-errors.png +0 -0
- package/screenshots/truth/list/fields-dragging.png +0 -0
- package/screenshots/truth/list/fields-filtered.png +0 -0
- package/screenshots/truth/list/fields-hovered.png +0 -0
- package/screenshots/truth/list/fields.png +0 -0
- package/screenshots/truth/list/items-selected.png +0 -0
- package/screenshots/truth/list/items-updated.png +0 -0
- package/screenshots/truth/list/items.png +0 -0
- package/screenshots/truth/menu/menu-focused-with items.png +0 -0
- package/screenshots/truth/menu/menu-refresh-1.png +0 -0
- package/screenshots/truth/menu/menu-refresh-2.png +0 -0
- package/screenshots/truth/menu/menu-submenu.png +0 -0
- package/screenshots/truth/menu/menu-tasks-nextup.png +0 -0
- package/screenshots/truth/menu/menu-tasks.png +0 -0
- package/screenshots/truth/message-editor/autogrow-initial-content.png +0 -0
- package/screenshots/truth/message-editor/default.png +0 -0
- package/screenshots/truth/message-editor/drag-highlight.png +0 -0
- package/screenshots/truth/message-editor/filtered-attachments.png +0 -0
- package/screenshots/truth/message-editor/with-completion.png +0 -0
- package/screenshots/truth/message-editor/with-properties.png +0 -0
- package/screenshots/truth/modax/form.png +0 -0
- package/screenshots/truth/modax/simple.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/information-extraction.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/sentiment-analysis.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/summarization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/editor/translation-task.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/information-extraction.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/sentiment-analysis.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/summarization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/translation-task.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/basic-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/custom-input-and-result-name.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/feedback-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/many-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/minimal-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/ab-test-multiple-variants.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/sampling-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/three-way-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/two-bucket-split.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/basic-digits-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/phone-number-collection.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/single-digit-with-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/verification-code.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/short-timeout.png +0 -0
- package/screenshots/truth/omnibox/selected.png +0 -0
- package/screenshots/truth/options/block.png +0 -0
- package/screenshots/truth/run-list/basic.png +0 -0
- package/screenshots/truth/select/disabled-multi-selection.png +0 -0
- package/screenshots/truth/select/disabled-selection.png +0 -0
- package/screenshots/truth/select/disabled.png +0 -0
- package/screenshots/truth/select/embedded.png +0 -0
- package/screenshots/truth/select/empty-options.png +0 -0
- package/screenshots/truth/select/expression-selected.png +0 -0
- package/screenshots/truth/select/expressions.png +0 -0
- package/screenshots/truth/select/functions.png +0 -0
- package/screenshots/truth/select/local-options.png +0 -0
- package/screenshots/truth/select/multi-with-endpoint.png +0 -0
- package/screenshots/truth/select/multiple-initial-values.png +0 -0
- package/screenshots/truth/select/remote-options.png +0 -0
- package/screenshots/truth/select/search-enabled.png +0 -0
- package/screenshots/truth/select/search-multi-no-matches.png +0 -0
- package/screenshots/truth/select/search-selected-focus.png +0 -0
- package/screenshots/truth/select/search-selected.png +0 -0
- package/screenshots/truth/select/search-with-selected.png +0 -0
- package/screenshots/truth/select/searching.png +0 -0
- package/screenshots/truth/select/selected-multi-maxitems-reached.png +0 -0
- package/screenshots/truth/select/selected-multi.png +0 -0
- package/screenshots/truth/select/selected-single.png +0 -0
- package/screenshots/truth/select/selection-clearable.png +0 -0
- package/screenshots/truth/select/static-initial-value.png +0 -0
- package/screenshots/truth/select/static-initial-via-selected.png +0 -0
- package/screenshots/truth/select/truncated-selection.png +0 -0
- package/screenshots/truth/select/with-placeholder.png +0 -0
- package/screenshots/truth/select/without-placeholder.png +0 -0
- package/screenshots/truth/slider/update-slider-on-circle-dragged.png +0 -0
- package/screenshots/truth/templates/default.png +0 -0
- package/screenshots/truth/templates/unapproved.png +0 -0
- package/screenshots/truth/textinput/autogrow-initial.png +0 -0
- package/screenshots/truth/textinput/input-disabled.png +0 -0
- package/screenshots/truth/textinput/input-focused.png +0 -0
- package/screenshots/truth/textinput/input-form.png +0 -0
- package/screenshots/truth/textinput/input-inserted.png +0 -0
- package/screenshots/truth/textinput/input-placeholder.png +0 -0
- package/screenshots/truth/textinput/input-updated.png +0 -0
- package/screenshots/truth/textinput/input.png +0 -0
- package/screenshots/truth/textinput/textarea-focused.png +0 -0
- package/screenshots/truth/textinput/textarea.png +0 -0
- package/src/events.ts +4 -2
- package/src/flow/Editor.ts +6 -3
- package/src/flow/actions/set_contact_channel.ts +1 -1
- package/src/flow/actions/set_contact_field.ts +1 -1
- package/src/flow/actions/set_contact_language.ts +1 -1
- package/src/flow/actions/set_contact_status.ts +1 -1
- package/src/flow/config.ts +2 -8
- package/src/flow/nodes/split_by_llm.ts +119 -0
- package/src/flow/nodes/split_by_llm_categorize.ts +13 -116
- package/src/flow/nodes/split_by_subflow.ts +153 -3
- package/src/flow/nodes/split_by_ticket.ts +135 -12
- package/src/flow/nodes/split_by_webhook.ts +187 -12
- package/src/live/ContactChat.ts +56 -58
- package/src/store/flow-definition.d.ts +2 -1
- package/src/utils.ts +192 -0
- package/test/nodes/split_by_llm.test.ts +232 -0
- package/test-assets/style.css +36 -234
- package/web-dev-server.config.mjs +26 -0
- package/web-test-runner.config.mjs +1 -1
- package/out-tsc/src/flow/actions/call_llm.js +0 -64
- package/out-tsc/src/flow/actions/call_llm.js.map +0 -1
- package/out-tsc/src/flow/actions/call_webhook.js +0 -131
- package/out-tsc/src/flow/actions/call_webhook.js.map +0 -1
- package/out-tsc/src/flow/actions/enter_flow.js +0 -14
- package/out-tsc/src/flow/actions/enter_flow.js.map +0 -1
- package/out-tsc/src/flow/actions/open_ticket.js +0 -73
- package/out-tsc/src/flow/actions/open_ticket.js.map +0 -1
- package/out-tsc/test/actions/call_llm.test.js +0 -103
- package/out-tsc/test/actions/call_llm.test.js.map +0 -1
- package/src/flow/actions/call_llm.ts +0 -66
- package/src/flow/actions/call_webhook.ts +0 -143
- package/src/flow/actions/enter_flow.ts +0 -15
- package/src/flow/actions/open_ticket.ts +0 -83
- package/test/actions/call_llm.test.ts +0 -137
|
@@ -1,18 +1,166 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { COLORS } from '../types';
|
|
2
|
+
import { generateUUID, createSuccessFailureRouter } from '../../utils';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
const defaultPost = `@(json(object(
|
|
5
|
+
"contact", object(
|
|
6
|
+
"uuid", contact.uuid,
|
|
7
|
+
"name", contact.name,
|
|
8
|
+
"urn", contact.urn
|
|
9
|
+
),
|
|
10
|
+
"flow", object(
|
|
11
|
+
"uuid", run.flow.uuid,
|
|
12
|
+
"name", run.flow.name
|
|
13
|
+
),
|
|
14
|
+
"results", foreach_value(results, extract_object, "value", "category")
|
|
15
|
+
)))`;
|
|
2
16
|
export const split_by_webhook = {
|
|
3
17
|
type: 'split_by_webhook',
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
name: 'Call Webhook',
|
|
19
|
+
color: COLORS.call,
|
|
20
|
+
form: {
|
|
21
|
+
method: {
|
|
22
|
+
type: 'select',
|
|
23
|
+
required: true,
|
|
24
|
+
options: ['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'PATCH'],
|
|
25
|
+
maxWidth: '120px',
|
|
26
|
+
searchable: false
|
|
27
|
+
},
|
|
28
|
+
url: {
|
|
29
|
+
type: 'text',
|
|
30
|
+
required: true,
|
|
31
|
+
evaluated: true,
|
|
32
|
+
placeholder: 'https://example.com/webhook'
|
|
33
|
+
},
|
|
34
|
+
headers: {
|
|
35
|
+
type: 'key-value',
|
|
36
|
+
sortable: true,
|
|
37
|
+
keyPlaceholder: 'Header name',
|
|
38
|
+
valuePlaceholder: 'Header value',
|
|
39
|
+
minRows: 0
|
|
40
|
+
},
|
|
41
|
+
body: {
|
|
42
|
+
type: 'textarea',
|
|
43
|
+
evaluated: true,
|
|
44
|
+
placeholder: 'Request body content (JSON, XML, etc.)',
|
|
45
|
+
minHeight: 200,
|
|
46
|
+
dependsOn: ['method'],
|
|
47
|
+
computeValue: (values, currentValue, originalValues) => {
|
|
48
|
+
// Check if method is POST (handle both string and select object formats)
|
|
49
|
+
const method = Array.isArray(values.method) && values.method.length > 0
|
|
50
|
+
? values.method[0].value || values.method[0].name
|
|
51
|
+
: values.method;
|
|
52
|
+
if (method === 'POST') {
|
|
53
|
+
// For POST, provide the template if body is empty or was never set by user
|
|
54
|
+
if (!currentValue || currentValue.trim() === '') {
|
|
55
|
+
return defaultPost;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// For non-POST methods, clear the body if it was auto-generated or empty
|
|
60
|
+
// Check if the original body was empty (user never specified a body)
|
|
61
|
+
const originalBody = (originalValues === null || originalValues === void 0 ? void 0 : originalValues.body) || '';
|
|
62
|
+
const isOriginallyEmpty = !originalBody || originalBody.trim() === '';
|
|
63
|
+
// Clear if: originally empty, contains default template, or is currently empty
|
|
64
|
+
if (isOriginallyEmpty ||
|
|
65
|
+
!currentValue ||
|
|
66
|
+
currentValue.trim() === '' ||
|
|
67
|
+
currentValue.trim() === defaultPost.trim()) {
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return currentValue; // Keep existing value if user has customized it
|
|
14
72
|
}
|
|
15
|
-
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
layout: [
|
|
76
|
+
// Row with method and URL side by side
|
|
77
|
+
{ type: 'row', items: ['method', 'url'] },
|
|
78
|
+
// Advanced group with nested layouts
|
|
79
|
+
{
|
|
80
|
+
type: 'group',
|
|
81
|
+
label: 'Headers',
|
|
82
|
+
items: ['headers'],
|
|
83
|
+
collapsible: true,
|
|
84
|
+
collapsed: true,
|
|
85
|
+
helpText: 'Configure authentication or custom headers',
|
|
86
|
+
getGroupValueCount: (formData) => {
|
|
87
|
+
var _a;
|
|
88
|
+
return ((_a = formData.headers) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'group',
|
|
93
|
+
label: 'Body',
|
|
94
|
+
items: ['body'],
|
|
95
|
+
collapsible: true,
|
|
96
|
+
collapsed: true,
|
|
97
|
+
helpText: 'Configure the request payload',
|
|
98
|
+
getGroupValueCount: (formData) => {
|
|
99
|
+
return !!(formData.body &&
|
|
100
|
+
formData.body.trim() !== '' &&
|
|
101
|
+
formData.body !== defaultPost);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
render: (node) => {
|
|
106
|
+
var _a;
|
|
107
|
+
const callWebhookAction = (_a = node.actions) === null || _a === void 0 ? void 0 : _a.find((action) => action.type === 'call_webhook');
|
|
108
|
+
return html `
|
|
109
|
+
<div
|
|
110
|
+
class="body"
|
|
111
|
+
style="word-wrap: break-word; overflow-wrap: break-word; hyphens: auto;"
|
|
112
|
+
>
|
|
113
|
+
${(callWebhookAction === null || callWebhookAction === void 0 ? void 0 : callWebhookAction.url) || 'Configure webhook'}
|
|
114
|
+
</div>
|
|
115
|
+
`;
|
|
116
|
+
},
|
|
117
|
+
toFormData: (node) => {
|
|
118
|
+
var _a;
|
|
119
|
+
// Extract data from the existing node structure
|
|
120
|
+
const callWebhookAction = (_a = node.actions) === null || _a === void 0 ? void 0 : _a.find((action) => action.type === 'call_webhook');
|
|
121
|
+
return {
|
|
122
|
+
uuid: node.uuid,
|
|
123
|
+
method: (callWebhookAction === null || callWebhookAction === void 0 ? void 0 : callWebhookAction.method)
|
|
124
|
+
? [{ value: callWebhookAction.method, name: callWebhookAction.method }]
|
|
125
|
+
: [{ value: 'GET', name: 'GET' }],
|
|
126
|
+
url: (callWebhookAction === null || callWebhookAction === void 0 ? void 0 : callWebhookAction.url) || '',
|
|
127
|
+
headers: (callWebhookAction === null || callWebhookAction === void 0 ? void 0 : callWebhookAction.headers) || [],
|
|
128
|
+
body: (callWebhookAction === null || callWebhookAction === void 0 ? void 0 : callWebhookAction.body) || ''
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
fromFormData: (formData, originalNode) => {
|
|
132
|
+
var _a, _b, _c;
|
|
133
|
+
// Get method selection
|
|
134
|
+
const methodSelection = Array.isArray(formData.method) && formData.method.length > 0
|
|
135
|
+
? formData.method[0]
|
|
136
|
+
: { value: 'GET', name: 'GET' };
|
|
137
|
+
// Find existing call_webhook action to preserve its UUID
|
|
138
|
+
const existingCallWebhookAction = (_a = originalNode.actions) === null || _a === void 0 ? void 0 : _a.find((action) => action.type === 'call_webhook');
|
|
139
|
+
const callWebhookUuid = (existingCallWebhookAction === null || existingCallWebhookAction === void 0 ? void 0 : existingCallWebhookAction.uuid) || generateUUID();
|
|
140
|
+
// Create call_webhook action
|
|
141
|
+
const callWebhookAction = {
|
|
142
|
+
type: 'call_webhook',
|
|
143
|
+
uuid: callWebhookUuid,
|
|
144
|
+
method: methodSelection.value,
|
|
145
|
+
url: formData.url || '',
|
|
146
|
+
headers: formData.headers || [],
|
|
147
|
+
body: formData.body || ''
|
|
148
|
+
};
|
|
149
|
+
// Create categories and exits for Success and Failure
|
|
150
|
+
const existingCategories = ((_b = originalNode.router) === null || _b === void 0 ? void 0 : _b.categories) || [];
|
|
151
|
+
const existingExits = originalNode.exits || [];
|
|
152
|
+
const existingCases = ((_c = originalNode.router) === null || _c === void 0 ? void 0 : _c.cases) || [];
|
|
153
|
+
const { router, exits } = createSuccessFailureRouter('@webhook.status', {
|
|
154
|
+
type: 'has_number_between',
|
|
155
|
+
arguments: ['200', '299']
|
|
156
|
+
}, existingCategories, existingExits, existingCases);
|
|
157
|
+
// Return the complete node
|
|
158
|
+
return {
|
|
159
|
+
uuid: originalNode.uuid,
|
|
160
|
+
actions: [callWebhookAction],
|
|
161
|
+
router: router,
|
|
162
|
+
exits: exits
|
|
163
|
+
};
|
|
16
164
|
}
|
|
17
165
|
};
|
|
18
166
|
//# sourceMappingURL=split_by_webhook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_by_webhook.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,MAAM,CAAC,MAAM,gBAAgB,GAAe;IAC1C,IAAI,EAAE,kBAAkB;IACxB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,eAAe,EAAE,SAAS;QAC1B,OAAO,EAAE,iBAAiB;QAC1B,KAAK,EAAE;YACL;gBACE,IAAI,EAAE,oBAAoB;gBAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;gBACzB,YAAY,EAAE,SAAS;aACxB;SACF;KACF;CACF,CAAC","sourcesContent":["import { call_webhook } from '../actions/call_webhook';\nimport { NodeConfig } from '../types';\n\nexport const split_by_webhook: NodeConfig = {\n type: 'split_by_webhook',\n action: call_webhook,\n router: {\n type: 'switch',\n defaultCategory: 'Failure',\n operand: '@webhook.status',\n rules: [\n {\n type: 'has_number_between',\n arguments: ['200', '299'],\n categoryName: 'Success'\n }\n ]\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"split_by_webhook.js","sourceRoot":"","sources":["../../../../src/flow/nodes/split_by_webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,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aAAa,GAAG,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC;QAC/C,MAAM,aAAa,GAAG,CAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,KAAK,KAAI,EAAE,CAAC;QAEvD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,0BAA0B,CAClD,iBAAiB,EACjB;YACE,IAAI,EAAE,oBAAoB;YAC1B,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;SAC1B,EACD,kBAAkB,EAClB,aAAa,EACb,aAAa,CACd,CAAC;QAEF,2BAA2B;QAC3B,OAAO;YACL,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,OAAO,EAAE,CAAC,iBAAiB,CAAC;YAC5B,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK;SACb,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { COLORS, NodeConfig } from '../types';\nimport { CallWebhook, Node } from '../../store/flow-definition';\nimport { generateUUID, createSuccessFailureRouter } from '../../utils';\nimport { html } from 'lit';\n\nconst defaultPost = `@(json(object(\n \"contact\", object(\n \"uuid\", contact.uuid, \n \"name\", contact.name, \n \"urn\", contact.urn\n ),\n \"flow\", object(\n \"uuid\", run.flow.uuid, \n \"name\", run.flow.name\n ),\n \"results\", foreach_value(results, extract_object, \"value\", \"category\")\n)))`;\n\nexport const split_by_webhook: NodeConfig = {\n type: 'split_by_webhook',\n name: 'Call Webhook',\n color: COLORS.call,\n form: {\n method: {\n type: 'select',\n required: true,\n options: ['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'PATCH'],\n maxWidth: '120px',\n searchable: false\n },\n url: {\n type: 'text',\n required: true,\n evaluated: true,\n placeholder: 'https://example.com/webhook'\n },\n headers: {\n type: 'key-value',\n sortable: true,\n keyPlaceholder: 'Header name',\n valuePlaceholder: 'Header value',\n minRows: 0\n },\n body: {\n type: 'textarea',\n evaluated: true,\n placeholder: 'Request body content (JSON, XML, etc.)',\n minHeight: 200,\n dependsOn: ['method'],\n computeValue: (\n values: Record<string, any>,\n currentValue: any,\n originalValues?: Record<string, any>\n ) => {\n // Check if method is POST (handle both string and select object formats)\n const method =\n Array.isArray(values.method) && values.method.length > 0\n ? values.method[0].value || values.method[0].name\n : values.method;\n\n if (method === 'POST') {\n // For POST, provide the template if body is empty or was never set by user\n if (!currentValue || currentValue.trim() === '') {\n return defaultPost;\n }\n } else {\n // For non-POST methods, clear the body if it was auto-generated or empty\n // Check if the original body was empty (user never specified a body)\n const originalBody = originalValues?.body || '';\n const isOriginallyEmpty = !originalBody || originalBody.trim() === '';\n\n // Clear if: originally empty, contains default template, or is currently empty\n if (\n isOriginallyEmpty ||\n !currentValue ||\n currentValue.trim() === '' ||\n currentValue.trim() === defaultPost.trim()\n ) {\n return '';\n }\n }\n\n return currentValue; // Keep existing value if user has customized it\n }\n }\n },\n layout: [\n // Row with method and URL side by side\n { type: 'row', items: ['method', 'url'] },\n // Advanced group with nested layouts\n {\n type: 'group',\n label: 'Headers',\n items: ['headers'],\n collapsible: true,\n collapsed: true,\n helpText: 'Configure authentication or custom headers',\n getGroupValueCount: (formData: any) => {\n return formData.headers?.length || 0;\n }\n },\n {\n type: 'group',\n label: 'Body',\n items: ['body'],\n collapsible: true,\n collapsed: true,\n helpText: 'Configure the request payload',\n getGroupValueCount: (formData: any) => {\n return !!(\n formData.body &&\n formData.body.trim() !== '' &&\n formData.body !== defaultPost\n );\n }\n }\n ],\n render: (node: Node) => {\n const callWebhookAction = node.actions?.find(\n (action) => action.type === 'call_webhook'\n ) as CallWebhook;\n return html`\n <div\n class=\"body\"\n style=\"word-wrap: break-word; overflow-wrap: break-word; hyphens: auto;\"\n >\n ${callWebhookAction?.url || 'Configure webhook'}\n </div>\n `;\n },\n toFormData: (node: Node) => {\n // Extract data from the existing node structure\n const callWebhookAction = node.actions?.find(\n (action) => action.type === 'call_webhook'\n ) as any;\n\n return {\n uuid: node.uuid,\n method: callWebhookAction?.method\n ? [{ value: callWebhookAction.method, name: callWebhookAction.method }]\n : [{ value: 'GET', name: 'GET' }],\n url: callWebhookAction?.url || '',\n headers: callWebhookAction?.headers || [],\n body: callWebhookAction?.body || ''\n };\n },\n fromFormData: (formData: any, originalNode: Node): Node => {\n // Get method selection\n const methodSelection =\n Array.isArray(formData.method) && formData.method.length > 0\n ? formData.method[0]\n : { value: 'GET', name: 'GET' };\n\n // Find existing call_webhook action to preserve its UUID\n const existingCallWebhookAction = originalNode.actions?.find(\n (action) => action.type === 'call_webhook'\n );\n const callWebhookUuid = existingCallWebhookAction?.uuid || generateUUID();\n\n // Create call_webhook action\n const callWebhookAction: CallWebhook = {\n type: 'call_webhook',\n uuid: callWebhookUuid,\n method: methodSelection.value,\n url: formData.url || '',\n headers: formData.headers || [],\n body: formData.body || ''\n };\n\n // Create categories and exits for Success and Failure\n const existingCategories = originalNode.router?.categories || [];\n const existingExits = originalNode.exits || [];\n const existingCases = originalNode.router?.cases || [];\n\n const { router, exits } = createSuccessFailureRouter(\n '@webhook.status',\n {\n type: 'has_number_between',\n arguments: ['200', '299']\n },\n existingCategories,\n existingExits,\n existingCases\n );\n\n // Return the complete node\n return {\n uuid: originalNode.uuid,\n actions: [callWebhookAction],\n router: router,\n exits: exits\n };\n }\n};\n"]}
|
|
@@ -27,6 +27,7 @@ export var Events;
|
|
|
27
27
|
Events["CONTACT_GROUPS_CHANGED"] = "contact_groups_changed";
|
|
28
28
|
Events["CONTACT_LANGUAGE_CHANGED"] = "contact_language_changed";
|
|
29
29
|
Events["CONTACT_NAME_CHANGED"] = "contact_name_changed";
|
|
30
|
+
Events["CONTACT_STATUS_CHANGED"] = "contact_status_changed";
|
|
30
31
|
Events["CONTACT_URNS_CHANGED"] = "contact_urns_changed";
|
|
31
32
|
Events["IVR_CREATED"] = "ivr_created";
|
|
32
33
|
Events["MSG_CREATED"] = "msg_created";
|
|
@@ -62,40 +63,12 @@ const renderInfoList = (singular, plural, items) => {
|
|
|
62
63
|
}
|
|
63
64
|
};
|
|
64
65
|
const renderChannelEvent = (event) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return 'Missed outgoing call';
|
|
68
|
-
}
|
|
69
|
-
else if (event.event.type === 'mo_miss') {
|
|
70
|
-
return 'Missed incoming call';
|
|
71
|
-
}
|
|
72
|
-
else if (event.event.type === 'new_conversation') {
|
|
73
|
-
return 'Started conversation';
|
|
74
|
-
}
|
|
75
|
-
else if (event.channel_event_type === 'welcome_message') {
|
|
76
|
-
return 'Welcome Message Sent';
|
|
77
|
-
}
|
|
78
|
-
else if (event.event.type === 'referral') {
|
|
79
|
-
return 'Referred';
|
|
80
|
-
}
|
|
81
|
-
else if (event.event.type === 'follow') {
|
|
82
|
-
return 'Followed';
|
|
66
|
+
if (event.channel_event_type === 'welcome_message') {
|
|
67
|
+
return 'Welcome message sent';
|
|
83
68
|
}
|
|
84
69
|
else if (event.event.type === 'stop_contact') {
|
|
85
70
|
return 'Stopped';
|
|
86
71
|
}
|
|
87
|
-
else if (event.event.type === 'mt_call') {
|
|
88
|
-
return 'Outgoing Phone Call'; // deprecated
|
|
89
|
-
}
|
|
90
|
-
else if (event.event.type == 'mo_call') {
|
|
91
|
-
return 'Incoming Phone call'; // deprecated
|
|
92
|
-
}
|
|
93
|
-
else if (event.event.type == 'optin') {
|
|
94
|
-
return `Opted in to **${(_a = event.event.optin) === null || _a === void 0 ? void 0 : _a.name}**`; // deprecated
|
|
95
|
-
}
|
|
96
|
-
else if (event.event.type == 'optout') {
|
|
97
|
-
return `Opted out of **${(_b = event.event.optin) === null || _b === void 0 ? void 0 : _b.name}**`; // deprecated
|
|
98
|
-
}
|
|
99
72
|
};
|
|
100
73
|
const renderRunEvent = (event) => {
|
|
101
74
|
let verb = 'Started';
|
|
@@ -165,6 +138,9 @@ export const renderAirtimeTransferredEvent = (event) => {
|
|
|
165
138
|
export const renderContactLanguageChangedEvent = (event) => {
|
|
166
139
|
return `Language updated to **${event.language}**`;
|
|
167
140
|
};
|
|
141
|
+
export const renderContactStatusChangedEvent = (event) => {
|
|
142
|
+
return `Status updated to **${event.status}**`;
|
|
143
|
+
};
|
|
168
144
|
export const renderCallEvent = (event) => {
|
|
169
145
|
if (event.type === Events.CALL_CREATED) {
|
|
170
146
|
return `Call started`;
|
|
@@ -178,7 +154,7 @@ export const renderCallEvent = (event) => {
|
|
|
178
154
|
};
|
|
179
155
|
export const renderOptInEvent = (event) => {
|
|
180
156
|
if (event.type === Events.OPTIN_REQUESTED) {
|
|
181
|
-
return `Requested opt-in for
|
|
157
|
+
return `Requested opt-in for **${event.optin.name}**`;
|
|
182
158
|
}
|
|
183
159
|
else if (event.type === Events.OPTIN_STARTED) {
|
|
184
160
|
return `Opted in to **${event.optin.name}**`;
|
|
@@ -523,53 +499,54 @@ export class ContactChat extends ContactStoreElement {
|
|
|
523
499
|
getEventMessage(event) {
|
|
524
500
|
let message = null;
|
|
525
501
|
switch (event.type) {
|
|
526
|
-
case Events.
|
|
502
|
+
case Events.AIRTIME_TRANSFERRED:
|
|
527
503
|
message = {
|
|
528
504
|
type: MessageType.Inline,
|
|
529
|
-
text:
|
|
505
|
+
text: renderAirtimeTransferredEvent(event)
|
|
530
506
|
};
|
|
531
507
|
break;
|
|
532
|
-
case Events.
|
|
508
|
+
case Events.CALL_CREATED:
|
|
509
|
+
case Events.CALL_MISSED:
|
|
510
|
+
case Events.CALL_RECEIVED:
|
|
533
511
|
message = {
|
|
534
512
|
type: MessageType.Inline,
|
|
535
|
-
text:
|
|
513
|
+
text: renderCallEvent(event)
|
|
536
514
|
};
|
|
537
515
|
break;
|
|
538
|
-
case Events.
|
|
516
|
+
case Events.CHAT_STARTED:
|
|
539
517
|
message = {
|
|
540
518
|
type: MessageType.Inline,
|
|
541
|
-
text:
|
|
519
|
+
text: renderChatStartedEvent(event)
|
|
542
520
|
};
|
|
543
521
|
break;
|
|
544
|
-
case Events.
|
|
522
|
+
case Events.CONTACT_FIELD_CHANGED:
|
|
545
523
|
message = {
|
|
546
524
|
type: MessageType.Inline,
|
|
547
|
-
text:
|
|
525
|
+
text: renderUpdateEvent(event)
|
|
548
526
|
};
|
|
549
527
|
break;
|
|
550
|
-
case Events.
|
|
528
|
+
case Events.CONTACT_GROUPS_CHANGED:
|
|
551
529
|
message = {
|
|
552
530
|
type: MessageType.Inline,
|
|
553
|
-
text:
|
|
531
|
+
text: renderContactGroupsEvent(event)
|
|
554
532
|
};
|
|
555
533
|
break;
|
|
556
|
-
case Events.
|
|
557
|
-
case Events.RUN_ENDED:
|
|
534
|
+
case Events.CONTACT_LANGUAGE_CHANGED:
|
|
558
535
|
message = {
|
|
559
536
|
type: MessageType.Inline,
|
|
560
|
-
text:
|
|
537
|
+
text: renderContactLanguageChangedEvent(event)
|
|
561
538
|
};
|
|
562
539
|
break;
|
|
563
|
-
case Events.
|
|
540
|
+
case Events.CONTACT_NAME_CHANGED:
|
|
564
541
|
message = {
|
|
565
542
|
type: MessageType.Inline,
|
|
566
|
-
text:
|
|
543
|
+
text: renderNameChanged(event)
|
|
567
544
|
};
|
|
568
545
|
break;
|
|
569
|
-
case Events.
|
|
546
|
+
case Events.CONTACT_STATUS_CHANGED:
|
|
570
547
|
message = {
|
|
571
548
|
type: MessageType.Inline,
|
|
572
|
-
text:
|
|
549
|
+
text: renderContactStatusChangedEvent(event)
|
|
573
550
|
};
|
|
574
551
|
break;
|
|
575
552
|
case Events.CONTACT_URNS_CHANGED:
|
|
@@ -578,50 +555,55 @@ export class ContactChat extends ContactStoreElement {
|
|
|
578
555
|
text: renderContactURNsChanged(event)
|
|
579
556
|
};
|
|
580
557
|
break;
|
|
581
|
-
case Events.
|
|
558
|
+
case Events.OPTIN_REQUESTED:
|
|
559
|
+
case Events.OPTIN_STARTED:
|
|
560
|
+
case Events.OPTIN_STOPPED:
|
|
582
561
|
message = {
|
|
583
562
|
type: MessageType.Inline,
|
|
584
|
-
text:
|
|
563
|
+
text: renderOptInEvent(event)
|
|
585
564
|
};
|
|
586
565
|
break;
|
|
587
|
-
case Events.
|
|
566
|
+
case Events.RUN_STARTED:
|
|
567
|
+
case Events.RUN_ENDED:
|
|
588
568
|
message = {
|
|
589
569
|
type: MessageType.Inline,
|
|
590
|
-
text:
|
|
570
|
+
text: renderRunEvent(event)
|
|
591
571
|
};
|
|
592
572
|
break;
|
|
593
|
-
case Events.
|
|
594
|
-
case Events.CALL_MISSED:
|
|
595
|
-
case Events.CALL_RECEIVED:
|
|
573
|
+
case Events.TICKET_ASSIGNED:
|
|
596
574
|
message = {
|
|
597
575
|
type: MessageType.Inline,
|
|
598
|
-
text:
|
|
576
|
+
text: renderTicketAssigned(event)
|
|
599
577
|
};
|
|
600
578
|
break;
|
|
601
|
-
case Events.
|
|
579
|
+
case Events.TICKET_CLOSED:
|
|
602
580
|
message = {
|
|
603
581
|
type: MessageType.Inline,
|
|
604
|
-
text:
|
|
582
|
+
text: renderTicketAction(event, 'closed')
|
|
605
583
|
};
|
|
606
584
|
break;
|
|
607
|
-
case Events.
|
|
585
|
+
case Events.TICKET_OPENED:
|
|
608
586
|
message = {
|
|
609
587
|
type: MessageType.Inline,
|
|
610
|
-
text:
|
|
588
|
+
text: renderTicketAction(event, 'opened')
|
|
611
589
|
};
|
|
612
590
|
break;
|
|
613
|
-
case Events.
|
|
591
|
+
case Events.TICKET_REOPENED:
|
|
614
592
|
message = {
|
|
615
593
|
type: MessageType.Inline,
|
|
616
|
-
text:
|
|
594
|
+
text: renderTicketAction(event, 'reopened')
|
|
617
595
|
};
|
|
618
596
|
break;
|
|
619
|
-
case Events.
|
|
620
|
-
case Events.OPTIN_STARTED:
|
|
621
|
-
case Events.OPTIN_STOPPED:
|
|
597
|
+
case Events.TICKET_TOPIC_CHANGED:
|
|
622
598
|
message = {
|
|
623
599
|
type: MessageType.Inline,
|
|
624
|
-
text:
|
|
600
|
+
text: `Topic changed to **${event.topic.name}**`
|
|
601
|
+
};
|
|
602
|
+
break;
|
|
603
|
+
case Events.CHANNEL_EVENT: // deprecated
|
|
604
|
+
message = {
|
|
605
|
+
type: MessageType.Inline,
|
|
606
|
+
text: renderChannelEvent(event)
|
|
625
607
|
};
|
|
626
608
|
break;
|
|
627
609
|
}
|