@tiledesk/tiledesk-server 3.0.0 → 3.1.0
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/.circleci/config.yml +1 -1
- package/CHANGELOG.md +37 -0
- package/Dockerfile +3 -2
- package/Dockerfile-en +3 -2
- package/Dockerfile-jobs +3 -2
- package/Dockerfile-profiler +3 -2
- package/README.md +15 -0
- package/app.js +14 -1
- package/bin/quota-reset +68 -0
- package/bin/quota-restore +86 -0
- package/channels/chat21/chat21Handler.js +50 -34
- package/channels/chat21/chat21JoinTracker.js +43 -0
- package/config/database.js +5 -5
- package/config/native_mcp/native_mcp_servers.json +1 -0
- package/controllers/chatbot.controller.js +80 -27
- package/controllers/intents.controller.js +42 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-chat21-ionic.md +468 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-design-studio.md +1349 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-server.md +1694 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-tybot.md +789 -0
- package/docs/superpowers/plans/2026-09-29-hitl-known-limits-server.md +83 -0
- package/docs/superpowers/plans/2026-09-29-hitl-known-limits-tybot.md +76 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-chat21-ionic.md +97 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-design-studio.md +72 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-server.md +223 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-tybot.md +121 -0
- package/docs/superpowers/plans/2026-09-29-hitl-pre-branch-ports.md +65 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-design-studio.md +88 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-server.md +103 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-tybot.md +43 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-design-studio.md +80 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-runtime.md +39 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-server.md +106 -0
- package/docs/superpowers/specs/2026-09-15-webhook-chatbot-hitl-design.md +715 -0
- package/docs/superpowers/specs/2026-09-30-flow-start-points-design.md +156 -0
- package/docs/superpowers/specs/2026-10-01-scheduled-start-point-design.md +303 -0
- package/docs/superpowers/todo/2026-09-14-webhook-chatbot-shared-code-fixes.md +191 -0
- package/event/botEvent.js +12 -1
- package/event/emailEvent.js +3 -0
- package/event/messageEvent.js +44 -0
- package/jobs.js +10 -0
- package/jobsManager.js +19 -0
- package/middleware/errorHandler.js +6 -2
- package/models/agentPrompt.js +104 -0
- package/models/analyticResult.js +1 -1
- package/models/channelConstants.js +3 -2
- package/models/quotaUsage.js +71 -0
- package/models/request.js +6 -0
- package/models/requestSnapshot.js +12 -0
- package/models/routerLogger.js +1 -1
- package/models/webhook.js +44 -0
- package/package.json +7 -5
- package/pubmodules/emailNotification/requestNotification.js +14 -22
- package/pubmodules/events/test/eventRoute.js +7 -6
- package/pubmodules/rules/conciergeBot.js +9 -4
- package/routes/agentPrompts.js +132 -0
- package/routes/auth.js +1 -12
- package/routes/campaigns.js +0 -13
- package/routes/dataTable.js +0 -3
- package/routes/faq_kb.js +12 -1
- package/routes/messagesRoot.js +0 -1
- package/routes/quotes.js +38 -1
- package/routes/request.js +81 -5
- package/routes/users.js +0 -1
- package/routes/webhook.js +160 -8
- package/routes/webhooks.js +276 -6
- package/routes/widgetLoader.js +6 -3
- package/services/QuoteManager.js +77 -16
- package/services/aiService.js +1 -1
- package/services/chatbotService.js +55 -1
- package/services/departmentService.js +60 -43
- package/services/dolphinSchedulerClient.js +116 -0
- package/services/emailService.js +6 -1
- package/services/hitlParticipantListener.js +260 -0
- package/services/participantInviteService.js +302 -0
- package/services/participantRemoveService.js +79 -0
- package/services/quotaSnapshotService.js +1167 -0
- package/services/requestService.js +102 -144
- package/services/scheduledStart/dolphinBackend.js +246 -0
- package/services/scheduledStart/schedulerBackend.js +101 -0
- package/services/scheduledStart/schedulerServiceClient.js +41 -0
- package/services/scheduledStartPublishListener.js +186 -0
- package/services/scheduledStartRules.js +173 -0
- package/services/scheduledStartService.js +130 -0
- package/services/startPointCleanupListener.js +30 -0
- package/services/startPointService.js +158 -0
- package/services/testWsService.js +1 -4
- package/services/updateRequestSnapshotQueued.js +8 -9
- package/services/webhookConversationService.js +185 -0
- package/services/webhookSettingsValidator.js +61 -0
- package/template/email/checkpointReachedEmail.html +5 -0
- package/test/agentPromptsRoute.test.js +154 -0
- package/test/agentTokensQuota.js +237 -0
- package/test/botEventHitlFallback.js +19 -0
- package/test/chat21HandlerJoinWiring.js +59 -0
- package/test/dataTablesRoute.test.js +10 -2
- package/test/dateUtils.test.js +0 -3
- package/test/departmentService.js +8 -12
- package/test/{fileRoute.js → deprecated/_deprecated_fileRoute} +2 -2
- package/test/{kbsettingsRoute.js → deprecated/_deprecated_kbsettingsRoute} +3 -3
- package/test/faqRoute.js +6 -1
- package/test/faqkbRoute.js +14 -10
- package/test/faqkbV3Route.js +1 -1
- package/test/filepRoute.js +4 -50
- package/test/hitlParticipantListener.js +446 -0
- package/test/hitlQueueWiring.js +191 -0
- package/test/hitlWaitingReset.js +124 -0
- package/test/inviteParticipantsRoute.js +492 -0
- package/test/kbRoute.js +1 -1
- package/test/messageRoute.js +33 -21
- package/test/nativemcp.test.js +7 -1
- package/test/openaiRoute.js +2 -8
- package/test/publishFailLoud.test.js +414 -0
- package/test/quotaSnapshots.js +1044 -0
- package/test/removeParticipantsRoute.js +186 -0
- package/test/requestService.js +24 -16
- package/test/requestServiceRemoveParticipant.js +144 -0
- package/test/requestVisibility.test.js +186 -0
- package/test/scheduledStartFacade.js +184 -0
- package/test/scheduledStartHandover.js +95 -0
- package/test/scheduledStartPublish.js +320 -0
- package/test/scheduledStartRoute.js +163 -0
- package/test/scheduledStartRules.js +177 -0
- package/test/scheduledStartRun.js +299 -0
- package/test/scheduledStartSchedulerBackend.js +116 -0
- package/test/scheduledStartService.js +290 -0
- package/test/startPointsCleanup.js +69 -0
- package/test/startPointsRegression.js +169 -0
- package/test/startPointsRoute.js +158 -0
- package/test/webhookConversationRoute.js +347 -0
- package/test/webhookConversationService.js +261 -0
- package/test/webhookConversationTestUtils.js +55 -0
- package/utils/aiUtils.js +95 -1
- package/utils/intentFieldNames.js +192 -0
- package/utils/quotaCliUtil.js +43 -0
- package/utils/requestVisibility.js +355 -0
- package/websocket/webSocketServer.js +36 -31
- /package/test/{imageRoute.js → deprecated/_deprecated_imageRoute} +0 -0
|
@@ -0,0 +1,1349 @@
|
|
|
1
|
+
# Webhook-started chatbot conversations + HITL — design-studio Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** Let flow designers enable a webhook on the start block of a conversational chatbot, add the "Invite human" action, and test a webhook start from Design Studio.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Pure helpers in `utils-webhook.ts` decide toggle state and the HTTP request to send; `WebhookService` gets two methods (`createStartWebhook`, `updateWebhookSettings`). The start block detail panel gets a start-only webhook section. The new action follows the `ifonlineagentsv2` pattern (model, registry, factory, component, switches, connectors, icon, i18n). A `ControllerService` subject lets the start panel ask the header to run a "webhook start" test that preloads a dev request and opens only the logs panel.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Angular, TypeScript, Angular Material, ngx-translate, Jasmine/Karma (`ng test`).
|
|
10
|
+
|
|
11
|
+
**Spec:** `tiledesk-server/docs/superpowers/specs/2026-09-15-webhook-chatbot-hitl-design.md` (sections 8, 9.3). Server API: `tiledesk-server/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-server.md` Task 1.
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Repo `design-studio`, branch `feature/webhook-chatbot-hitl` created from `origin/master` (`c5972d94`, 1.40.14). Never commit to `master`.
|
|
16
|
+
- Path aliases used below: `C = src/app/chatbot-design-studio`, `CV = C/cds-dashboard/cds-canvas`.
|
|
17
|
+
- Webhook mode value: exactly `'conversation'`. Action type: exactly `'invite_human'`. The `TYPE_ACTION` enum key and the `ACTIONS_LIST` key must both be `INVITE_HUMAN` (`CV/cds-intent/cds-intent.component.ts:751-766` looks the list up by enum key).
|
|
18
|
+
- The start webhook UI is shown only for chatbots with subtype `chatbot` (or no subtype).
|
|
19
|
+
- Never call `webhookService.deleteWebhook` to turn the start webhook off — it only stops a dev preload (`DELETE /webhooks/preload/:id`).
|
|
20
|
+
- Do not touch the lazy auto-create for blocks named `webhook` (`CV/cds-intent/cds-intent.component.ts:265-272`).
|
|
21
|
+
- `strictTemplates` is off: template bindings are not type-checked; review every new binding against the component inputs/outputs listed in the tasks.
|
|
22
|
+
- **Deviations from spec §8 (agreed during planning):**
|
|
23
|
+
- "Test webhook start" is launched from a button in the start block webhook section, not from the play menu: `PLAY_MENU_ITEMS` has no trigger in `cds-header.component.html` (the `#menuPlay` menu is never opened).
|
|
24
|
+
- The small webhook badge on the start block header is not implemented in v1 (it would need a webhook lookup per block render).
|
|
25
|
+
- Commit messages end with `Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>`.
|
|
26
|
+
|
|
27
|
+
### How to run tests
|
|
28
|
+
```bash
|
|
29
|
+
cd /Users/nicocardone/Desktop/DEV/TILEDESK/design-studio
|
|
30
|
+
npx ng test --watch=false --browsers=ChromeHeadless --include=<spec path>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## File Structure
|
|
36
|
+
|
|
37
|
+
| File | Status | Responsibility |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
| `C/utils-webhook.ts` | Create | `WEBHOOK_MODE_CONVERSATION`, `isStartWebhookActive`, `needsSwitchConfirmation`, `startWebhookToggleRequest` |
|
|
40
|
+
| `C/utils-webhook.spec.ts` | Create | helper tests |
|
|
41
|
+
| `C/services/webhook-service.service.ts` | Modify | `createStartWebhook`, `updateWebhookSettings` |
|
|
42
|
+
| `C/services/webhook-service.service.spec.ts` | Modify | HTTP shape tests |
|
|
43
|
+
| `CV/cds-panel-intent-detail/cds-panel-intent-detail.component.ts` / `.html` | Modify | start webhook section |
|
|
44
|
+
| `src/assets/i18n/en.json` | Modify | new labels |
|
|
45
|
+
| `src/app/models/action-model.ts` | Modify | `ActionInviteHuman` |
|
|
46
|
+
| `C/utils-actions.ts` | Modify | `TYPE_ACTION.INVITE_HUMAN`, `ACTIONS_LIST.INVITE_HUMAN` |
|
|
47
|
+
| `C/services/intent.service.ts` | Modify | factory branch; `webhookStartTest` flag |
|
|
48
|
+
| `CV/actions/list/cds-action-invite-human/*` | Create | action component (ts, html, scss, spec) |
|
|
49
|
+
| `CV/actions/list/cds-actions.module.ts` | Modify | declare/export component |
|
|
50
|
+
| `CV/cds-intent/cds-intent.component.html`, `CV/cds-panel-action-detail/cds-panel-action-detail.component.html` | Modify | switch cases |
|
|
51
|
+
| `C/services/connector.service.ts` | Modify | redraw true/false connectors |
|
|
52
|
+
| `C/services/icon.service.ts`, `src/assets/images/actions/invite_human.svg` | Modify/Create | icon |
|
|
53
|
+
| `C/services/controller.service.ts` | Modify | `webhookStartTestRequested$` |
|
|
54
|
+
| `C/cds-dashboard/cds-header/cds-header.component.ts` / `.html` | Modify | run/stop webhook start test |
|
|
55
|
+
| `CV/cds-canvas.component.ts` | Modify | don't open the widget during a webhook start test |
|
|
56
|
+
| `CV/cds-intent/cds-intent.component.ts` | Modify | highlight start block during a webhook start test |
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### Task 1: Branch, webhook helpers and service methods
|
|
61
|
+
|
|
62
|
+
**Files:**
|
|
63
|
+
- Create: `C/utils-webhook.ts`, `C/utils-webhook.spec.ts`
|
|
64
|
+
- Modify: `C/services/webhook-service.service.ts`
|
|
65
|
+
- Modify: `C/services/webhook-service.service.spec.ts`
|
|
66
|
+
|
|
67
|
+
**Interfaces:**
|
|
68
|
+
- Produces:
|
|
69
|
+
- `WEBHOOK_MODE_CONVERSATION = 'conversation'`
|
|
70
|
+
- `isStartWebhookActive(webhook: any): boolean`
|
|
71
|
+
- `needsSwitchConfirmation(webhook: any): boolean`
|
|
72
|
+
- `type StartWebhookToggleRequest = {type: 'none'} | {type: 'create'} | {type: 'update', patch: {enabled: boolean, mode?: string, block_id?: string}}`
|
|
73
|
+
- `startWebhookToggleRequest(webhook: any, enable: boolean, startIntentId: string): StartWebhookToggleRequest`
|
|
74
|
+
- `WebhookService.createStartWebhook(chatbot_id: string, block_id: string, opts?: {department_id?: string, source_name?: string}): Observable<any>`
|
|
75
|
+
- `WebhookService.updateWebhookSettings(chatbot_id: string, patch: {enabled?: boolean, mode?: string, block_id?: string, department_id?: string | null, source_name?: string}): Observable<any>`
|
|
76
|
+
|
|
77
|
+
- [ ] **Step 1: Create the feature branch**
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
cd /Users/nicocardone/Desktop/DEV/TILEDESK/design-studio
|
|
81
|
+
git fetch origin
|
|
82
|
+
git switch -c feature/webhook-chatbot-hitl origin/master
|
|
83
|
+
git branch --unset-upstream
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- [ ] **Step 2: Write the failing helper tests**
|
|
87
|
+
|
|
88
|
+
Create `src/app/chatbot-design-studio/utils-webhook.spec.ts`:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import { isStartWebhookActive, needsSwitchConfirmation, startWebhookToggleRequest, WEBHOOK_MODE_CONVERSATION } from './utils-webhook';
|
|
92
|
+
|
|
93
|
+
describe('utils-webhook', () => {
|
|
94
|
+
|
|
95
|
+
it('isStartWebhookActive is true only for enabled conversation webhooks', () => {
|
|
96
|
+
expect(isStartWebhookActive(null)).toBeFalse();
|
|
97
|
+
expect(isStartWebhookActive({ webhook_id: 'w1', enabled: true })).toBeFalse();
|
|
98
|
+
expect(isStartWebhookActive({ webhook_id: 'w1', mode: 'conversation', enabled: false })).toBeFalse();
|
|
99
|
+
expect(isStartWebhookActive({ webhook_id: 'w1', mode: 'conversation', enabled: true })).toBeTrue();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('needsSwitchConfirmation is true only for an existing automation webhook', () => {
|
|
103
|
+
expect(needsSwitchConfirmation(null)).toBeFalse();
|
|
104
|
+
expect(needsSwitchConfirmation({ webhook_id: 'w1', mode: 'conversation' })).toBeFalse();
|
|
105
|
+
expect(needsSwitchConfirmation({ webhook_id: 'w1' })).toBeTrue();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('startWebhookToggleRequest creates, switches, disables or does nothing', () => {
|
|
109
|
+
expect(startWebhookToggleRequest(null, true, 'start-id')).toEqual({ type: 'create' });
|
|
110
|
+
expect(startWebhookToggleRequest({ webhook_id: 'w1' }, true, 'start-id'))
|
|
111
|
+
.toEqual({ type: 'update', patch: { enabled: true, mode: WEBHOOK_MODE_CONVERSATION, block_id: 'start-id' } });
|
|
112
|
+
expect(startWebhookToggleRequest({ webhook_id: 'w1', mode: 'conversation' }, false, 'start-id'))
|
|
113
|
+
.toEqual({ type: 'update', patch: { enabled: false } });
|
|
114
|
+
expect(startWebhookToggleRequest(null, false, 'start-id')).toEqual({ type: 'none' });
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
- [ ] **Step 3: Replace the service spec with failing HTTP tests**
|
|
120
|
+
|
|
121
|
+
Replace the whole content of `src/app/chatbot-design-studio/services/webhook-service.service.spec.ts` with:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { TestBed } from '@angular/core/testing';
|
|
125
|
+
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
|
|
126
|
+
import { WebhookService } from './webhook-service.service';
|
|
127
|
+
import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
|
|
128
|
+
import { IntentService } from './intent.service';
|
|
129
|
+
|
|
130
|
+
describe('WebhookService', () => {
|
|
131
|
+
let service: WebhookService;
|
|
132
|
+
let httpMock: HttpTestingController;
|
|
133
|
+
|
|
134
|
+
beforeEach(() => {
|
|
135
|
+
TestBed.configureTestingModule({
|
|
136
|
+
imports: [HttpClientTestingModule],
|
|
137
|
+
providers: [
|
|
138
|
+
WebhookService,
|
|
139
|
+
{ provide: AppStorageService, useValue: { getItem: () => 'JWT test-token' } },
|
|
140
|
+
{ provide: IntentService, useValue: { listOfIntents: [] } }
|
|
141
|
+
]
|
|
142
|
+
});
|
|
143
|
+
service = TestBed.inject(WebhookService);
|
|
144
|
+
httpMock = TestBed.inject(HttpTestingController);
|
|
145
|
+
service.initialize('https://api.test/', 'project1');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
afterEach(() => {
|
|
149
|
+
httpMock.verify();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('createStartWebhook posts a conversation-mode webhook bound to the start block', () => {
|
|
153
|
+
service.createStartWebhook('bot1', 'start-intent', { department_id: 'dep1', source_name: 'Grafana alerts' }).subscribe();
|
|
154
|
+
|
|
155
|
+
const req = httpMock.expectOne('https://api.test/project1/webhooks/');
|
|
156
|
+
expect(req.request.method).toBe('POST');
|
|
157
|
+
expect(req.request.headers.get('Authorization')).toBe('JWT test-token');
|
|
158
|
+
expect(JSON.parse(req.request.body)).toEqual({
|
|
159
|
+
chatbot_id: 'bot1', block_id: 'start-intent', mode: 'conversation', department_id: 'dep1', source_name: 'Grafana alerts'
|
|
160
|
+
});
|
|
161
|
+
req.flush({ webhook_id: 'w1' });
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('updateWebhookSettings puts only the given fields', () => {
|
|
165
|
+
service.updateWebhookSettings('bot1', { enabled: false }).subscribe();
|
|
166
|
+
|
|
167
|
+
const req = httpMock.expectOne('https://api.test/project1/webhooks/bot1');
|
|
168
|
+
expect(req.request.method).toBe('PUT');
|
|
169
|
+
expect(JSON.parse(req.request.body)).toEqual({ enabled: false });
|
|
170
|
+
req.flush({ webhook_id: 'w1' });
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
- [ ] **Step 4: Run the tests to verify they fail**
|
|
176
|
+
|
|
177
|
+
Run:
|
|
178
|
+
```bash
|
|
179
|
+
npx ng test --watch=false --browsers=ChromeHeadless --include=src/app/chatbot-design-studio/utils-webhook.spec.ts --include=src/app/chatbot-design-studio/services/webhook-service.service.spec.ts
|
|
180
|
+
```
|
|
181
|
+
Expected: FAIL — compilation errors `Cannot find module './utils-webhook'` and `Property 'createStartWebhook' does not exist on type 'WebhookService'`.
|
|
182
|
+
|
|
183
|
+
- [ ] **Step 5: Implement the helpers**
|
|
184
|
+
|
|
185
|
+
Create `src/app/chatbot-design-studio/utils-webhook.ts`:
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
export const WEBHOOK_MODE_CONVERSATION = 'conversation';
|
|
189
|
+
|
|
190
|
+
export type StartWebhookToggleRequest =
|
|
191
|
+
| { type: 'none' }
|
|
192
|
+
| { type: 'create' }
|
|
193
|
+
| { type: 'update', patch: { enabled: boolean, mode?: string, block_id?: string } };
|
|
194
|
+
|
|
195
|
+
/** The start block webhook is "on" only for enabled webhooks in conversation mode */
|
|
196
|
+
export function isStartWebhookActive(webhook: any): boolean {
|
|
197
|
+
return !!(webhook && webhook.webhook_id && webhook.mode === WEBHOOK_MODE_CONVERSATION && webhook.enabled !== false);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** An existing webhook without mode runs a block headless: switching it changes its behaviour */
|
|
201
|
+
export function needsSwitchConfirmation(webhook: any): boolean {
|
|
202
|
+
return !!(webhook && webhook.webhook_id && webhook.mode !== WEBHOOK_MODE_CONVERSATION);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function startWebhookToggleRequest(webhook: any, enable: boolean, startIntentId: string): StartWebhookToggleRequest {
|
|
206
|
+
const exists = !!(webhook && webhook.webhook_id);
|
|
207
|
+
if (enable) {
|
|
208
|
+
if (!exists) {
|
|
209
|
+
return { type: 'create' };
|
|
210
|
+
}
|
|
211
|
+
return { type: 'update', patch: { enabled: true, mode: WEBHOOK_MODE_CONVERSATION, block_id: startIntentId } };
|
|
212
|
+
}
|
|
213
|
+
return exists ? { type: 'update', patch: { enabled: false } } : { type: 'none' };
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
- [ ] **Step 6: Implement the service methods**
|
|
218
|
+
|
|
219
|
+
In `src/app/chatbot-design-studio/services/webhook-service.service.ts`, add after `import { IntentService } from './intent.service';`:
|
|
220
|
+
|
|
221
|
+
```ts
|
|
222
|
+
import { WEBHOOK_MODE_CONVERSATION } from '../utils-webhook';
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
and add these methods right before `preloadWebhook(webhook_id: string){`:
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
createStartWebhook(chatbot_id: string, block_id: string, opts: { department_id?: string, source_name?: string } = {}){
|
|
229
|
+
this.tiledeskToken = this.appStorageService.getItem('tiledeskToken');
|
|
230
|
+
this.logger.log('[WEBHOOK_URL.SERV] createStartWebhook');
|
|
231
|
+
const httpOptions = {
|
|
232
|
+
headers: new HttpHeaders({
|
|
233
|
+
'Accept': 'application/json',
|
|
234
|
+
'Content-Type': 'application/json',
|
|
235
|
+
'Authorization': this.tiledeskToken
|
|
236
|
+
})
|
|
237
|
+
};
|
|
238
|
+
const body = Object.assign({ chatbot_id: chatbot_id, block_id: block_id, mode: WEBHOOK_MODE_CONVERSATION }, opts);
|
|
239
|
+
const url = this.WEBHOOK_URL + '/webhooks/';
|
|
240
|
+
return this._httpClient.post<any>(url, JSON.stringify(body), httpOptions);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
updateWebhookSettings(chatbot_id: string, patch: { enabled?: boolean, mode?: string, block_id?: string, department_id?: string | null, source_name?: string }){
|
|
244
|
+
this.tiledeskToken = this.appStorageService.getItem('tiledeskToken');
|
|
245
|
+
this.logger.log('[WEBHOOK_URL.SERV] updateWebhookSettings', patch);
|
|
246
|
+
const httpOptions = {
|
|
247
|
+
headers: new HttpHeaders({
|
|
248
|
+
'Accept': 'application/json',
|
|
249
|
+
'Content-Type': 'application/json',
|
|
250
|
+
'Authorization': this.tiledeskToken
|
|
251
|
+
})
|
|
252
|
+
};
|
|
253
|
+
const url = this.WEBHOOK_URL + '/webhooks/' + chatbot_id;
|
|
254
|
+
return this._httpClient.put<any>(url, JSON.stringify(patch), httpOptions);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
- [ ] **Step 7: Run the tests to verify they pass**
|
|
260
|
+
|
|
261
|
+
Run the command from Step 4.
|
|
262
|
+
Expected: PASS (5 specs, 0 failures).
|
|
263
|
+
|
|
264
|
+
- [ ] **Step 8: Commit**
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
git add src/app/chatbot-design-studio/utils-webhook.ts src/app/chatbot-design-studio/utils-webhook.spec.ts src/app/chatbot-design-studio/services/webhook-service.service.ts src/app/chatbot-design-studio/services/webhook-service.service.spec.ts
|
|
268
|
+
git commit -m "feat(webhook): add start webhook helpers and settings API methods
|
|
269
|
+
|
|
270
|
+
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>"
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
### Task 2: Start block webhook section
|
|
276
|
+
|
|
277
|
+
**Files:**
|
|
278
|
+
- Modify: `CV/cds-panel-intent-detail/cds-panel-intent-detail.component.ts` (imports, fields, `initializeStart` `:100-103`, `regenerateWebhook` `:184-196`)
|
|
279
|
+
- Modify: `CV/cds-panel-intent-detail/cds-panel-intent-detail.component.html` (new section after the "Agents available" row, which ends before `<!-- webhook -->`)
|
|
280
|
+
- Modify: `src/assets/i18n/en.json` (`CDSCanvas`, after `"DevelopmentUrl":"Development Url",` at `:620`)
|
|
281
|
+
|
|
282
|
+
**Interfaces:**
|
|
283
|
+
- Consumes: Task 1 helpers and service methods; `DashboardService.departments: Department[]` (`{_id, name}`), `DashboardService.selectedChatbot.subtype`, `DashboardService.id_faq_kb`; `cds-select` inputs `items`, `bindLabelSelect`, `bindValueSelect`, `itemSelected`, `placeholder`, `clearable`, outputs `onSelected` (emits the selected item), `onReset`.
|
|
284
|
+
- Produces: component fields `isChatbotStart`, `startWebhook`, `startWebhookActive`, `startWebhookDepartmentId`, `startWebhookSourceName`, `departments`; methods `loadStartWebhook()`, `onStartWebhookToggle(enable: boolean)`, `onStartWebhookDepartmentChange(item)`, `onStartWebhookDepartmentReset()`, `onStartWebhookSourceNameSave()`, `onCopyStartUrl(value: string)`.
|
|
285
|
+
|
|
286
|
+
- [ ] **Step 1: Add the translations**
|
|
287
|
+
|
|
288
|
+
In `src/assets/i18n/en.json`, after `"DevelopmentUrl":"Development Url",` add:
|
|
289
|
+
|
|
290
|
+
```json
|
|
291
|
+
"StartWebhook": "Start from webhook",
|
|
292
|
+
"InfoStartWebhook": "Lets an external system start this chatbot with an HTTP call, exactly like a new widget conversation.",
|
|
293
|
+
"InfoStartWebhookBranch": "Webhook starts set the variables webhook_http_method and payload: branch on them in the start flow to tell webhook and widget conversations apart.",
|
|
294
|
+
"StartWebhookDepartment": "Conversation department",
|
|
295
|
+
"StartWebhookSourceName": "Source name",
|
|
296
|
+
"StartWebhookSwitchTitle": "Switch webhook",
|
|
297
|
+
"StartWebhookSwitchText": "This chatbot already has a webhook that runs a block without a conversation. Switching it will make calls start conversations from the start block. Continue?",
|
|
298
|
+
"StartWebhookSwitchConfirm": "Switch",
|
|
299
|
+
"StartWebhookSwitchCancel": "Cancel",
|
|
300
|
+
"StartWebhookError": "Unable to update the webhook",
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
- [ ] **Step 2: Add imports and fields to the component**
|
|
304
|
+
|
|
305
|
+
In `cds-panel-intent-detail.component.ts`, add after `import { PanelIntentHeaderComponent } from '../cds-intent/panel-intent-header/panel-intent-header.component';`:
|
|
306
|
+
|
|
307
|
+
```ts
|
|
308
|
+
import { Department } from 'src/app/models/department-model';
|
|
309
|
+
import { isStartWebhookActive, needsSwitchConfirmation, startWebhookToggleRequest } from 'src/app/chatbot-design-studio/utils-webhook';
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Add after `chatbotSubtype: string;`:
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
|
|
316
|
+
/* start webhook params (conversational chatbots) */
|
|
317
|
+
isChatbotStart: boolean = false;
|
|
318
|
+
startWebhook: any = null;
|
|
319
|
+
startWebhookActive: boolean = false;
|
|
320
|
+
startWebhookDepartmentId: string | null = null;
|
|
321
|
+
startWebhookSourceName: string = '';
|
|
322
|
+
departments: Department[] = [];
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
- [ ] **Step 3: Load the start webhook when the start panel opens**
|
|
326
|
+
|
|
327
|
+
Replace:
|
|
328
|
+
|
|
329
|
+
```ts
|
|
330
|
+
initializeStart(){
|
|
331
|
+
this.isStart = true;
|
|
332
|
+
if(this.intent.agents_available !== false) this.intent.agents_available = true;
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
with:
|
|
337
|
+
|
|
338
|
+
```ts
|
|
339
|
+
initializeStart(){
|
|
340
|
+
this.isStart = true;
|
|
341
|
+
if(this.intent.agents_available !== false) this.intent.agents_available = true;
|
|
342
|
+
const subtype = this.dashboardService.selectedChatbot?.subtype || TYPE_CHATBOT.CHATBOT;
|
|
343
|
+
if (subtype === TYPE_CHATBOT.CHATBOT) {
|
|
344
|
+
this.isChatbotStart = true;
|
|
345
|
+
this.project_id = this.dashboardService.projectID;
|
|
346
|
+
this.serverBaseURL = this.appConfigService.getConfig().apiUrl;
|
|
347
|
+
this.chatbot_id = this.dashboardService.id_faq_kb;
|
|
348
|
+
this.departments = this.dashboardService.departments || [];
|
|
349
|
+
this.loadStartWebhook();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
loadStartWebhook(){
|
|
354
|
+
this.webhookService.getWebhook(this.chatbot_id).subscribe({ next: (resp: any) => {
|
|
355
|
+
this.applyStartWebhook(resp);
|
|
356
|
+
}, error: (error) => {
|
|
357
|
+
// 404 when the chatbot has no webhook yet
|
|
358
|
+
this.logger.log("[CdsPanelIntentDetailComponent] loadStartWebhook: no webhook ", error);
|
|
359
|
+
this.applyStartWebhook(null);
|
|
360
|
+
}});
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
private applyStartWebhook(webhook: any){
|
|
364
|
+
this.startWebhook = (webhook && webhook.webhook_id) ? webhook : null;
|
|
365
|
+
this.startWebhookActive = isStartWebhookActive(this.startWebhook);
|
|
366
|
+
this.webhookUrl = this.startWebhook ? this.serverBaseURL + 'webhook/' + this.startWebhook.webhook_id : '';
|
|
367
|
+
this.webhookUrlDev = this.webhookUrl ? this.webhookUrl + '/dev' : '';
|
|
368
|
+
this.startWebhookDepartmentId = this.startWebhook?.department_id || null;
|
|
369
|
+
this.startWebhookSourceName = this.startWebhook?.source_name || '';
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
onStartWebhookToggle(enable: boolean){
|
|
373
|
+
if (enable && needsSwitchConfirmation(this.startWebhook)) {
|
|
374
|
+
swal({
|
|
375
|
+
title: this.translate.instant('CDSCanvas.StartWebhookSwitchTitle'),
|
|
376
|
+
text: this.translate.instant('CDSCanvas.StartWebhookSwitchText'),
|
|
377
|
+
icon: "warning",
|
|
378
|
+
buttons: [this.translate.instant('CDSCanvas.StartWebhookSwitchCancel'), this.translate.instant('CDSCanvas.StartWebhookSwitchConfirm')],
|
|
379
|
+
dangerMode: false,
|
|
380
|
+
}).then((resp: boolean) => {
|
|
381
|
+
if (resp) {
|
|
382
|
+
this.applyStartWebhookToggle(true);
|
|
383
|
+
} else {
|
|
384
|
+
this.startWebhookActive = false;
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
this.applyStartWebhookToggle(enable);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
private applyStartWebhookToggle(enable: boolean){
|
|
393
|
+
const request = startWebhookToggleRequest(this.startWebhook, enable, this.intent.intent_id);
|
|
394
|
+
if (request.type === 'none') {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
const call$ = request.type === 'create'
|
|
398
|
+
? this.webhookService.createStartWebhook(this.chatbot_id, this.intent.intent_id)
|
|
399
|
+
: this.webhookService.updateWebhookSettings(this.chatbot_id, request.patch);
|
|
400
|
+
call$.subscribe({ next: (resp: any) => {
|
|
401
|
+
this.applyStartWebhook(resp);
|
|
402
|
+
}, error: (error) => {
|
|
403
|
+
this.logger.error("[CdsPanelIntentDetailComponent] start webhook toggle error: ", error);
|
|
404
|
+
this.startWebhookActive = isStartWebhookActive(this.startWebhook);
|
|
405
|
+
this.showMessage(this.translate.instant('CDSCanvas.StartWebhookError'));
|
|
406
|
+
}});
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
onStartWebhookDepartmentChange(item: any){
|
|
410
|
+
this.updateStartWebhookSettings({ department_id: item ? item._id : null });
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
onStartWebhookDepartmentReset(){
|
|
414
|
+
this.updateStartWebhookSettings({ department_id: null });
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
onStartWebhookSourceNameSave(){
|
|
418
|
+
this.updateStartWebhookSettings({ source_name: this.startWebhookSourceName });
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
private updateStartWebhookSettings(patch: { department_id?: string | null, source_name?: string }){
|
|
422
|
+
if (!this.startWebhook) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
this.webhookService.updateWebhookSettings(this.chatbot_id, patch).subscribe({ next: (resp: any) => {
|
|
426
|
+
this.applyStartWebhook(resp);
|
|
427
|
+
}, error: (error) => {
|
|
428
|
+
this.logger.error("[CdsPanelIntentDetailComponent] updateStartWebhookSettings error: ", error);
|
|
429
|
+
this.showMessage(this.translate.instant('CDSCanvas.StartWebhookError'));
|
|
430
|
+
}});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
onCopyStartUrl(value: string){
|
|
434
|
+
navigator.clipboard.writeText(value).then(() => {
|
|
435
|
+
this.showMessage(this.translate.instant('Copied') + '!');
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
- [ ] **Step 4: Keep the start webhook in sync after regenerate**
|
|
441
|
+
|
|
442
|
+
In `regenerateWebhook()`, replace:
|
|
443
|
+
|
|
444
|
+
```ts
|
|
445
|
+
this.logger.log("[CdsPanelIntentDetailComponent] regenerateWebhook : ", resp);
|
|
446
|
+
this.webhookUrl = this.serverBaseURL+'webhook/'+resp.webhook_id;
|
|
447
|
+
this.webhookUrlDev = this.webhookUrl+"/dev";
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
with:
|
|
451
|
+
|
|
452
|
+
```ts
|
|
453
|
+
this.logger.log("[CdsPanelIntentDetailComponent] regenerateWebhook : ", resp);
|
|
454
|
+
if (this.isChatbotStart) {
|
|
455
|
+
this.applyStartWebhook(resp);
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
this.webhookUrl = this.serverBaseURL+'webhook/'+resp.webhook_id;
|
|
459
|
+
this.webhookUrlDev = this.webhookUrl+"/dev";
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
- [ ] **Step 5: Add the template section**
|
|
463
|
+
|
|
464
|
+
In `cds-panel-intent-detail.component.html`, insert immediately before the comment block that starts with `<!-- webhook -->` (the `<!-- ---… -->` line right above it):
|
|
465
|
+
|
|
466
|
+
```html
|
|
467
|
+
<!-- ---------------------------------------------------------- -->
|
|
468
|
+
<!-- start webhook (conversational chatbots) -->
|
|
469
|
+
<!-- ---------------------------------------------------------- -->
|
|
470
|
+
<div *ngIf="isStart && isChatbotStart" class="row start-webhook">
|
|
471
|
+
|
|
472
|
+
<div class="nw-onoffswitch-wrapper">
|
|
473
|
+
<div class="nw-onoffswitch">
|
|
474
|
+
<label class="nw-onoffswitch-label" for="start_webhook_switch" [class.checked]="startWebhookActive">
|
|
475
|
+
<input type="checkbox" name="start_webhook_switch"
|
|
476
|
+
class="nw-onoffswitch-checkbox" id="start_webhook_switch"
|
|
477
|
+
[(ngModel)]="startWebhookActive"
|
|
478
|
+
(change)="onStartWebhookToggle($event.target.checked)" />
|
|
479
|
+
</label>
|
|
480
|
+
</div>
|
|
481
|
+
<span class="checkmark">{{ 'CDSCanvas.StartWebhook' | translate }}</span>
|
|
482
|
+
</div>
|
|
483
|
+
<span class="nw-onoffswitch-wrapper info">{{ 'CDSCanvas.InfoStartWebhook' | translate }}</span>
|
|
484
|
+
|
|
485
|
+
<ng-container *ngIf="startWebhookActive && webhookUrl">
|
|
486
|
+
<div>
|
|
487
|
+
<div>{{ 'CDSCanvas.ProductionUrl' | translate }}</div>
|
|
488
|
+
<div class="webhook-block">
|
|
489
|
+
<input #startCopyInput class="webhook-link" type="text" readonly [value]="webhookUrl">
|
|
490
|
+
<div class="webhook-icon end" (click)="onCopyStartUrl(startCopyInput.value)">
|
|
491
|
+
<mat-icon class="icon" svgIcon="copy" aria-hidden="true"></mat-icon>
|
|
492
|
+
</div>
|
|
493
|
+
</div>
|
|
494
|
+
</div>
|
|
495
|
+
|
|
496
|
+
<div>
|
|
497
|
+
<div>{{ 'CDSCanvas.DevelopmentUrl' | translate }}</div>
|
|
498
|
+
<div class="webhook-block">
|
|
499
|
+
<input #startCopyInputDev class="webhook-link" type="text" readonly [value]="webhookUrlDev">
|
|
500
|
+
<div class="webhook-icon end" (click)="onCopyStartUrl(startCopyInputDev.value)">
|
|
501
|
+
<mat-icon class="icon" svgIcon="copy" aria-hidden="true"></mat-icon>
|
|
502
|
+
</div>
|
|
503
|
+
</div>
|
|
504
|
+
</div>
|
|
505
|
+
|
|
506
|
+
<div class="field-box">
|
|
507
|
+
<label class="title-label">{{ 'CDSCanvas.StartWebhookDepartment' | translate }}</label>
|
|
508
|
+
<cds-select id="start-webhook-department"
|
|
509
|
+
[items]="departments"
|
|
510
|
+
[bindLabelSelect]="'name'"
|
|
511
|
+
[bindValueSelect]="'_id'"
|
|
512
|
+
[itemSelected]="startWebhookDepartmentId"
|
|
513
|
+
[placeholder]="'CDSCanvas.SelectADepartment' | translate"
|
|
514
|
+
[clearable]="true"
|
|
515
|
+
(onSelected)="onStartWebhookDepartmentChange($event)"
|
|
516
|
+
(onReset)="onStartWebhookDepartmentReset()">
|
|
517
|
+
</cds-select>
|
|
518
|
+
</div>
|
|
519
|
+
|
|
520
|
+
<div class="field-box">
|
|
521
|
+
<label class="title-label">{{ 'CDSCanvas.StartWebhookSourceName' | translate }}</label>
|
|
522
|
+
<input class="webhook-link" type="text" [(ngModel)]="startWebhookSourceName" (change)="onStartWebhookSourceNameSave()">
|
|
523
|
+
</div>
|
|
524
|
+
|
|
525
|
+
<span class="nw-onoffswitch-wrapper info">{{ 'CDSCanvas.InfoStartWebhookBranch' | translate }}</span>
|
|
526
|
+
|
|
527
|
+
<div class="webhook-buttons">
|
|
528
|
+
<button type="button" class="btn btn-primary cds-blue-button" (click)="onRegenerateWebhook()">{{ 'Regenerate' | translate }}</button>
|
|
529
|
+
</div>
|
|
530
|
+
|
|
531
|
+
<p *ngIf="messageText" class="webhook-message fade-in-out">{{ messageText }}</p>
|
|
532
|
+
</ng-container>
|
|
533
|
+
</div>
|
|
534
|
+
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
- [ ] **Step 6: Build**
|
|
538
|
+
|
|
539
|
+
Run: `npx ng build`
|
|
540
|
+
Expected: build completes without errors.
|
|
541
|
+
|
|
542
|
+
- [ ] **Step 7: Manual verification (local DS against a server with Task 1 of the server plan)**
|
|
543
|
+
|
|
544
|
+
1. Open a chatbot (subtype `chatbot`), click the start block: the "Start from webhook" toggle is off.
|
|
545
|
+
2. Turn it on: production/dev URLs appear; `GET /:projectid/webhooks/:chatbot_id` returns `mode: 'conversation'` and `block_id` = start intent id.
|
|
546
|
+
3. Change department and source name: the PUT returns the new values; reopening the panel shows them.
|
|
547
|
+
4. Turn it off: PUT `{enabled:false}`; URLs disappear; no `DELETE /webhooks/preload/...` is sent.
|
|
548
|
+
5. On a chatbot that already has a webhook without mode, turning it on shows the switch confirmation; Cancel leaves the toggle off.
|
|
549
|
+
6. Open an automation bot (subtype `webhook`): the start-webhook section is not shown; the existing webhook block panel is unchanged.
|
|
550
|
+
|
|
551
|
+
- [ ] **Step 8: Commit**
|
|
552
|
+
|
|
553
|
+
```bash
|
|
554
|
+
git add src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-intent-detail/cds-panel-intent-detail.component.ts src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-intent-detail/cds-panel-intent-detail.component.html src/assets/i18n/en.json
|
|
555
|
+
git commit -m "feat(start-block): enable a conversation webhook on the start block
|
|
556
|
+
|
|
557
|
+
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>"
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
---
|
|
561
|
+
|
|
562
|
+
### Task 3: "Invite human" action
|
|
563
|
+
|
|
564
|
+
**Files:**
|
|
565
|
+
- Modify: `src/app/models/action-model.ts` (after `ActionOnlineAgentV2`, `:78-95`)
|
|
566
|
+
- Modify: `C/utils-actions.ts` (`TYPE_ACTION` enum end `:55-56`; `ACTIONS_LIST` after the `ONLINE_AGENTSV2:` entry `:141`)
|
|
567
|
+
- Modify: `C/services/intent.service.ts` (import at `:4`; `createNewAction` after the `ONLINE_AGENTSV2` branch `:1025-1027`)
|
|
568
|
+
- Create: `CV/actions/list/cds-action-invite-human/cds-action-invite-human.component.ts`, `.html`, `.scss`, `.spec.ts`
|
|
569
|
+
- Modify: `CV/actions/list/cds-actions.module.ts` (`:78`, declarations `:120`, exports `:242`)
|
|
570
|
+
- Modify: `CV/cds-intent/cds-intent.component.html` (after the `cds-action-online-agents-v2` case `:212-218`)
|
|
571
|
+
- Modify: `CV/cds-panel-action-detail/cds-panel-action-detail.component.html` (after the `cds-action-online-agents-v2` case `:84-91`)
|
|
572
|
+
- Modify: `C/services/connector.service.ts:523`
|
|
573
|
+
- Modify: `C/services/icon.service.ts` (after the `online_agents.svg` registration `:229-232`)
|
|
574
|
+
- Create: `src/assets/images/actions/invite_human.svg`
|
|
575
|
+
- Modify: `src/assets/i18n/en.json` (`CDSActionList.NAME`, `CDSActionList.DOC`, `CDSCanvas`)
|
|
576
|
+
|
|
577
|
+
**Interfaces:**
|
|
578
|
+
- Consumes: `checkConnectionStatusOfAction`, `updateConnector` (`src/app/chatbot-design-studio/utils-connectors`), `TYPE_UPDATE_ACTION` (`C/utils`), `IntentService.isChangedConnector$`, `IntentService.getListOfIntents()`, `DashboardService.departments`; `cds-textarea` inputs `text`, `placeholder`, `showUtils`, `setAttributeBtn`, `emojiPikerBtn`, `textLimitBtn`, `minRow`, `maxRow`, output `changeTextarea` (emits the trimmed text).
|
|
579
|
+
- Produces: `TYPE_ACTION.INVITE_HUMAN = 'invite_human'`; `class ActionInviteHuman { departmentId?: string; members?: string; trueIntent: string; falseIntent: string; trueIntentAttributes?: string; falseIntentAttributes?: string }`; `CdsActionInviteHumanComponent` (selector `cds-action-invite-human`, inputs `intentSelected`, `action`, `previewMode`, outputs `updateAndSaveAction`, `onConnectorChange`).
|
|
580
|
+
|
|
581
|
+
- [ ] **Step 1: Add the enum value and the model**
|
|
582
|
+
|
|
583
|
+
In `src/app/chatbot-design-studio/utils-actions.ts`, replace the end of `TYPE_ACTION`:
|
|
584
|
+
|
|
585
|
+
```ts
|
|
586
|
+
WEB_RESPONSE = 'web_response',
|
|
587
|
+
DATA_TABLE = 'data_table'
|
|
588
|
+
}
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
with:
|
|
592
|
+
|
|
593
|
+
```ts
|
|
594
|
+
WEB_RESPONSE = 'web_response',
|
|
595
|
+
DATA_TABLE = 'data_table',
|
|
596
|
+
INVITE_HUMAN = 'invite_human'
|
|
597
|
+
}
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
In `src/app/models/action-model.ts`, after the closing `}` of `class ActionOnlineAgentV2`, add:
|
|
601
|
+
|
|
602
|
+
```ts
|
|
603
|
+
|
|
604
|
+
export class ActionInviteHuman extends Action {
|
|
605
|
+
departmentId?: string;
|
|
606
|
+
members?: string;
|
|
607
|
+
trueIntent: string;
|
|
608
|
+
falseIntent: string;
|
|
609
|
+
trueIntentAttributes?: string;
|
|
610
|
+
falseIntentAttributes?: string;
|
|
611
|
+
constructor() {
|
|
612
|
+
super();
|
|
613
|
+
this._tdActionType = TYPE_ACTION.INVITE_HUMAN;
|
|
614
|
+
this.members = '';
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
- [ ] **Step 2: Create the component spec (failing)**
|
|
620
|
+
|
|
621
|
+
Create `CV/actions/list/cds-action-invite-human/cds-action-invite-human.component.spec.ts` (full path `src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-invite-human/cds-action-invite-human.component.spec.ts`):
|
|
622
|
+
|
|
623
|
+
```ts
|
|
624
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
625
|
+
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
626
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
627
|
+
import { Subject } from 'rxjs';
|
|
628
|
+
import { CdsActionInviteHumanComponent } from './cds-action-invite-human.component';
|
|
629
|
+
import { IntentService } from '../../../../../services/intent.service';
|
|
630
|
+
import { DashboardService } from 'src/app/services/dashboard.service';
|
|
631
|
+
import { ActionInviteHuman } from 'src/app/models/action-model';
|
|
632
|
+
|
|
633
|
+
describe('CdsActionInviteHumanComponent', () => {
|
|
634
|
+
let component: CdsActionInviteHumanComponent;
|
|
635
|
+
let fixture: ComponentFixture<CdsActionInviteHumanComponent>;
|
|
636
|
+
|
|
637
|
+
beforeEach(async () => {
|
|
638
|
+
await TestBed.configureTestingModule({
|
|
639
|
+
imports: [TranslateModule.forRoot()],
|
|
640
|
+
declarations: [CdsActionInviteHumanComponent],
|
|
641
|
+
providers: [
|
|
642
|
+
{ provide: IntentService, useValue: { isChangedConnector$: new Subject<any>(), getListOfIntents: () => [] } },
|
|
643
|
+
{ provide: DashboardService, useValue: { departments: [{ _id: 'dep1', name: 'SRE' }] } }
|
|
644
|
+
],
|
|
645
|
+
schemas: [NO_ERRORS_SCHEMA]
|
|
646
|
+
}).compileComponents();
|
|
647
|
+
|
|
648
|
+
fixture = TestBed.createComponent(CdsActionInviteHumanComponent);
|
|
649
|
+
component = fixture.componentInstance;
|
|
650
|
+
component.action = new ActionInviteHuman();
|
|
651
|
+
component.intentSelected = { intent_id: 'intent1' } as any;
|
|
652
|
+
component.previewMode = false;
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
it('creates an action with type invite_human', () => {
|
|
656
|
+
fixture.detectChanges();
|
|
657
|
+
expect(component.action._tdActionType).toBe('invite_human');
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
it('drops a department that does not belong to the project', () => {
|
|
661
|
+
component.action.departmentId = 'missing';
|
|
662
|
+
fixture.detectChanges();
|
|
663
|
+
expect(component.action.departmentId).toBeNull();
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
it('saves department and members', () => {
|
|
667
|
+
fixture.detectChanges();
|
|
668
|
+
const emitSpy = spyOn(component.updateAndSaveAction, 'emit');
|
|
669
|
+
|
|
670
|
+
component.onChangeDepartment({ _id: 'dep1', name: 'SRE' });
|
|
671
|
+
component.onChangeMembers('a@acme.it, {{oncall}}');
|
|
672
|
+
|
|
673
|
+
expect(component.action.departmentId).toBe('dep1');
|
|
674
|
+
expect(component.action.members).toBe('a@acme.it, {{oncall}}');
|
|
675
|
+
expect(emitSpy).toHaveBeenCalledTimes(2);
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
it('emits connector changes for the invited and no-human connectors', () => {
|
|
679
|
+
fixture.detectChanges();
|
|
680
|
+
const connectorSpy = spyOn(component.onConnectorChange, 'emit');
|
|
681
|
+
const actionId = component.action._tdActionId;
|
|
682
|
+
|
|
683
|
+
component.onChangeSelect({ name: 'next', value: '#next' }, 'trueIntent');
|
|
684
|
+
component.onResetBlockSelect({ name: 'next', value: '#next' }, 'falseIntent');
|
|
685
|
+
|
|
686
|
+
expect(connectorSpy).toHaveBeenCalledWith({ type: 'create', fromId: 'intent1/' + actionId + '/true', toId: '#next' });
|
|
687
|
+
expect(connectorSpy).toHaveBeenCalledWith({ type: 'delete', fromId: 'intent1/' + actionId + '/false', toId: undefined });
|
|
688
|
+
expect(component.action.falseIntent).toBeNull();
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
- [ ] **Step 3: Run the spec to verify it fails**
|
|
694
|
+
|
|
695
|
+
Run: `npx ng test --watch=false --browsers=ChromeHeadless --include=src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-invite-human/cds-action-invite-human.component.spec.ts`
|
|
696
|
+
Expected: FAIL — `Cannot find module './cds-action-invite-human.component'`.
|
|
697
|
+
|
|
698
|
+
- [ ] **Step 4: Create the component**
|
|
699
|
+
|
|
700
|
+
Create `cds-action-invite-human.component.ts` (same folder):
|
|
701
|
+
|
|
702
|
+
```ts
|
|
703
|
+
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
|
|
704
|
+
import { Subscription } from 'rxjs/internal/Subscription';
|
|
705
|
+
import { IntentService } from '../../../../../services/intent.service';
|
|
706
|
+
import { Intent } from 'src/app/models/intent-model';
|
|
707
|
+
import { ActionInviteHuman } from 'src/app/models/action-model';
|
|
708
|
+
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
709
|
+
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
710
|
+
import { TYPE_UPDATE_ACTION } from '../../../../../utils';
|
|
711
|
+
import { DashboardService } from 'src/app/services/dashboard.service';
|
|
712
|
+
import { Department } from 'src/app/models/department-model';
|
|
713
|
+
import { checkConnectionStatusOfAction, updateConnector } from 'src/app/chatbot-design-studio/utils-connectors';
|
|
714
|
+
|
|
715
|
+
@Component({
|
|
716
|
+
selector: 'cds-action-invite-human',
|
|
717
|
+
templateUrl: './cds-action-invite-human.component.html',
|
|
718
|
+
styleUrls: ['./cds-action-invite-human.component.scss']
|
|
719
|
+
})
|
|
720
|
+
export class CdsActionInviteHumanComponent implements OnInit, OnDestroy {
|
|
721
|
+
|
|
722
|
+
@Input() intentSelected: Intent;
|
|
723
|
+
@Input() action: ActionInviteHuman;
|
|
724
|
+
@Input() previewMode: boolean = true;
|
|
725
|
+
@Output() updateAndSaveAction = new EventEmitter();
|
|
726
|
+
@Output() onConnectorChange = new EventEmitter<{type: 'create' | 'delete', fromId: string, toId: string}>();
|
|
727
|
+
|
|
728
|
+
idIntentSelected: string;
|
|
729
|
+
idConnectorTrue: string;
|
|
730
|
+
idConnectorFalse: string;
|
|
731
|
+
idConnectionTrue: string;
|
|
732
|
+
idConnectionFalse: string;
|
|
733
|
+
isConnectedTrue: boolean = false;
|
|
734
|
+
isConnectedFalse: boolean = false;
|
|
735
|
+
connector: any;
|
|
736
|
+
|
|
737
|
+
listOfIntents: Array<{name: string, value: string, icon?: string}> = [];
|
|
738
|
+
departments: Department[] = [];
|
|
739
|
+
|
|
740
|
+
private subscriptionChangedConnector: Subscription;
|
|
741
|
+
private readonly logger: LoggerService = LoggerInstance.getInstance();
|
|
742
|
+
|
|
743
|
+
constructor(
|
|
744
|
+
private readonly intentService: IntentService,
|
|
745
|
+
private readonly dashboardService: DashboardService,
|
|
746
|
+
) { }
|
|
747
|
+
|
|
748
|
+
ngOnInit(): void {
|
|
749
|
+
this.subscriptionChangedConnector = this.intentService.isChangedConnector$.subscribe((connector: any) => {
|
|
750
|
+
const connectorId = this.idIntentSelected + "/" + this.action._tdActionId;
|
|
751
|
+
if (connector && connector.fromId && connector.fromId.startsWith(connectorId)) {
|
|
752
|
+
this.connector = connector;
|
|
753
|
+
this.updateConnector();
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
this.initialize();
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
ngOnDestroy(): void {
|
|
760
|
+
if (this.subscriptionChangedConnector) {
|
|
761
|
+
this.subscriptionChangedConnector.unsubscribe();
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
get selectedDepartmentName(): string {
|
|
766
|
+
const department = this.departments.find((dep) => dep._id === this.action?.departmentId);
|
|
767
|
+
return department ? department.name : '';
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
private initialize() {
|
|
771
|
+
this.departments = this.dashboardService.departments || [];
|
|
772
|
+
// chatbot imported from another project: reset a department that does not exist here
|
|
773
|
+
if (this.action.departmentId && this.departments.findIndex((dep) => dep._id === this.action.departmentId) === -1) {
|
|
774
|
+
this.action.departmentId = null;
|
|
775
|
+
}
|
|
776
|
+
if (this.intentSelected) {
|
|
777
|
+
this.initializeConnector();
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
private initializeConnector() {
|
|
782
|
+
this.idIntentSelected = this.intentSelected.intent_id;
|
|
783
|
+
this.idConnectorTrue = this.idIntentSelected + '/' + this.action._tdActionId + '/true';
|
|
784
|
+
this.idConnectorFalse = this.idIntentSelected + '/' + this.action._tdActionId + '/false';
|
|
785
|
+
this.listOfIntents = this.intentService.getListOfIntents();
|
|
786
|
+
this.checkConnectionStatus();
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
private checkConnectionStatus() {
|
|
790
|
+
const resp = checkConnectionStatusOfAction(this.action, this.idConnectorTrue, this.idConnectorFalse);
|
|
791
|
+
this.isConnectedTrue = resp.isConnectedTrue;
|
|
792
|
+
this.isConnectedFalse = resp.isConnectedFalse;
|
|
793
|
+
this.idConnectionTrue = resp.idConnectionTrue;
|
|
794
|
+
this.idConnectionFalse = resp.idConnectionFalse;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
private updateConnector() {
|
|
798
|
+
const resp = updateConnector(this.connector, this.action, this.isConnectedTrue, this.isConnectedFalse, this.idConnectionTrue, this.idConnectionFalse);
|
|
799
|
+
if (resp) {
|
|
800
|
+
this.isConnectedTrue = resp.isConnectedTrue;
|
|
801
|
+
this.isConnectedFalse = resp.isConnectedFalse;
|
|
802
|
+
this.idConnectionTrue = resp.idConnectionTrue;
|
|
803
|
+
this.idConnectionFalse = resp.idConnectionFalse;
|
|
804
|
+
if (resp.emit) {
|
|
805
|
+
this.updateAndSaveAction.emit({ type: TYPE_UPDATE_ACTION.CONNECTOR, element: this.connector });
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
onChangeDepartment(item: any) {
|
|
811
|
+
this.action.departmentId = item ? item._id : null;
|
|
812
|
+
this.updateAndSaveAction.emit({ type: TYPE_UPDATE_ACTION.ACTION, element: this.action });
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
onResetDepartment() {
|
|
816
|
+
this.action.departmentId = null;
|
|
817
|
+
this.updateAndSaveAction.emit({ type: TYPE_UPDATE_ACTION.ACTION, element: this.action });
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
onChangeMembers(text: string) {
|
|
821
|
+
this.action.members = text;
|
|
822
|
+
this.updateAndSaveAction.emit({ type: TYPE_UPDATE_ACTION.ACTION, element: this.action });
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
onChangeSelect(event: {name: string, value: string}, type: 'trueIntent' | 'falseIntent') {
|
|
826
|
+
if (!event) {
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
this.action[type] = event.value;
|
|
830
|
+
const fromId = type === 'trueIntent' ? this.idConnectorTrue : this.idConnectorFalse;
|
|
831
|
+
this.onConnectorChange.emit({ type: 'create', fromId: fromId, toId: this.action[type] });
|
|
832
|
+
this.updateAndSaveAction.emit({ type: TYPE_UPDATE_ACTION.ACTION, element: this.action });
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
onResetBlockSelect(event: {name: string, value: string}, type: 'trueIntent' | 'falseIntent') {
|
|
836
|
+
const fromId = type === 'trueIntent' ? this.idConnectorTrue : this.idConnectorFalse;
|
|
837
|
+
this.onConnectorChange.emit({ type: 'delete', fromId: fromId, toId: this.action[type] });
|
|
838
|
+
this.action[type] = null;
|
|
839
|
+
this.updateAndSaveAction.emit({ type: TYPE_UPDATE_ACTION.ACTION, element: this.action });
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
Create `cds-action-invite-human.component.html`:
|
|
845
|
+
|
|
846
|
+
```html
|
|
847
|
+
<div *ngIf="previewMode" class="cds-action-preview">
|
|
848
|
+
|
|
849
|
+
<div class="action-row">
|
|
850
|
+
<div class="action-row-left">
|
|
851
|
+
<span class="material-icons">person_add</span>
|
|
852
|
+
</div>
|
|
853
|
+
<div class="action-row-right">
|
|
854
|
+
<span *ngIf="action?.members"><b>{{ action.members }}</b></span>
|
|
855
|
+
<span *ngIf="!action?.members && selectedDepartmentName"><b>{{ selectedDepartmentName }}</b></span>
|
|
856
|
+
<span *ngIf="!action?.members && !selectedDepartmentName" class="empty">{{ 'CDSCanvas.InviteHumanConversationDepartment' | translate }}</span>
|
|
857
|
+
</div>
|
|
858
|
+
</div>
|
|
859
|
+
|
|
860
|
+
<div class="previewContent">
|
|
861
|
+
<label class="title-preview-label"><b>{{ 'CDSCanvas.InviteHumanInvited' | translate }}</b></label>
|
|
862
|
+
<cds-connector class="connector-true"
|
|
863
|
+
[idConnector]="idConnectorTrue"
|
|
864
|
+
[idConnection]="idConnectionTrue"
|
|
865
|
+
[isConnected]="isConnectedTrue">
|
|
866
|
+
</cds-connector>
|
|
867
|
+
</div>
|
|
868
|
+
|
|
869
|
+
<hr class="preview-divider">
|
|
870
|
+
|
|
871
|
+
<div class="previewContent">
|
|
872
|
+
<label class="title-preview-label">{{ 'CDSCanvas.InviteHumanNoHuman' | translate }}</label>
|
|
873
|
+
<cds-connector class="connector-false"
|
|
874
|
+
[idConnector]="idConnectorFalse"
|
|
875
|
+
[idConnection]="idConnectionFalse"
|
|
876
|
+
[isConnected]="isConnectedFalse">
|
|
877
|
+
</cds-connector>
|
|
878
|
+
</div>
|
|
879
|
+
|
|
880
|
+
</div>
|
|
881
|
+
|
|
882
|
+
<div *ngIf="!previewMode">
|
|
883
|
+
<div class="content-panel-intent-detail">
|
|
884
|
+
|
|
885
|
+
<div class="field-box">
|
|
886
|
+
<label class="title-label">{{ 'CDSCanvas.InviteHumanDepartment' | translate }}</label>
|
|
887
|
+
<cds-select id="invite-human-department"
|
|
888
|
+
[items]="departments"
|
|
889
|
+
[bindLabelSelect]="'name'"
|
|
890
|
+
[bindValueSelect]="'_id'"
|
|
891
|
+
[itemSelected]="action?.departmentId"
|
|
892
|
+
[placeholder]="'CDSCanvas.InviteHumanConversationDepartment' | translate"
|
|
893
|
+
[clearable]="true"
|
|
894
|
+
(onSelected)="onChangeDepartment($event)"
|
|
895
|
+
(onReset)="onResetDepartment()">
|
|
896
|
+
</cds-select>
|
|
897
|
+
</div>
|
|
898
|
+
|
|
899
|
+
<div class="field-box">
|
|
900
|
+
<label class="title-label">{{ 'CDSCanvas.InviteHumanMembers' | translate }}</label>
|
|
901
|
+
<cds-textarea id="invite-human-members"
|
|
902
|
+
[text]="action?.members"
|
|
903
|
+
[placeholder]="'CDSCanvas.InviteHumanMembersPlaceholder' | translate"
|
|
904
|
+
[showUtils]="true"
|
|
905
|
+
[setAttributeBtn]="true"
|
|
906
|
+
[emojiPikerBtn]="false"
|
|
907
|
+
[textLimitBtn]="false"
|
|
908
|
+
[minRow]="1"
|
|
909
|
+
[maxRow]="4"
|
|
910
|
+
(changeTextarea)="onChangeMembers($event)">
|
|
911
|
+
</cds-textarea>
|
|
912
|
+
<label class="field-description">{{ 'CDSCanvas.InviteHumanMembersDescription' | translate }}</label>
|
|
913
|
+
</div>
|
|
914
|
+
|
|
915
|
+
<hr class="custom-divider">
|
|
916
|
+
|
|
917
|
+
<div class="field-box">
|
|
918
|
+
<div class="condition-container">
|
|
919
|
+
<span class="condition-text">{{ 'CDSCanvas.InviteHumanInvited' | translate }}</span>
|
|
920
|
+
</div>
|
|
921
|
+
<cds-select id="invite-human-true"
|
|
922
|
+
[items]="listOfIntents"
|
|
923
|
+
[bindLabelSelect]="'name'"
|
|
924
|
+
[bindValueSelect]="'value'"
|
|
925
|
+
[itemSelected]="action?.trueIntent"
|
|
926
|
+
[placeholder]="'CDSCanvas.SelectABlock' | translate"
|
|
927
|
+
[clearable]="true"
|
|
928
|
+
(onSelected)="onChangeSelect($event, 'trueIntent')"
|
|
929
|
+
(onReset)="onResetBlockSelect($event, 'trueIntent')">
|
|
930
|
+
</cds-select>
|
|
931
|
+
</div>
|
|
932
|
+
|
|
933
|
+
<div class="field-box">
|
|
934
|
+
<div class="condition-container">
|
|
935
|
+
<span class="condition-text">{{ 'CDSCanvas.InviteHumanNoHuman' | translate }}</span>
|
|
936
|
+
</div>
|
|
937
|
+
<cds-select id="invite-human-false"
|
|
938
|
+
[items]="listOfIntents"
|
|
939
|
+
[bindLabelSelect]="'name'"
|
|
940
|
+
[bindValueSelect]="'value'"
|
|
941
|
+
[itemSelected]="action?.falseIntent"
|
|
942
|
+
[placeholder]="'CDSCanvas.SelectABlock' | translate"
|
|
943
|
+
[clearable]="true"
|
|
944
|
+
(onSelected)="onChangeSelect($event, 'falseIntent')"
|
|
945
|
+
(onReset)="onResetBlockSelect($event, 'falseIntent')">
|
|
946
|
+
</cds-select>
|
|
947
|
+
</div>
|
|
948
|
+
|
|
949
|
+
</div>
|
|
950
|
+
</div>
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
Create the stylesheet by copying the template action's styles:
|
|
954
|
+
|
|
955
|
+
```bash
|
|
956
|
+
cp src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-online-agents-v2/cds-action-online-agents.component.scss \
|
|
957
|
+
src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-invite-human/cds-action-invite-human.component.scss
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
- [ ] **Step 5: Run the spec to verify it passes**
|
|
961
|
+
|
|
962
|
+
Run the command from Step 3.
|
|
963
|
+
Expected: PASS (4 specs, 0 failures).
|
|
964
|
+
|
|
965
|
+
- [ ] **Step 6: Register the action everywhere**
|
|
966
|
+
|
|
967
|
+
`C/utils-actions.ts` — after the line starting with ` ONLINE_AGENTSV2:` in `ACTIONS_LIST`, add:
|
|
968
|
+
|
|
969
|
+
```ts
|
|
970
|
+
INVITE_HUMAN: { name: 'CDSActionList.NAME.InviteHuman', chatbot_types: [TYPE_CHATBOT.CHATBOT], category: TYPE_ACTION_CATEGORY.MOST_USED, type: TYPE_ACTION.INVITE_HUMAN, src: "assets/images/actions/invite_human.svg", status: "active", doc: "CDSActionList.DOC.InviteHuman" },
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
`C/services/intent.service.ts` — in the long `import { … } from 'src/app/models/action-model';` statement (line 4) add `ActionInviteHuman` to the list (e.g. right after `ActionOnlineAgentV2,`). In `createNewAction`, replace:
|
|
974
|
+
|
|
975
|
+
```ts
|
|
976
|
+
if(typeAction === TYPE_ACTION.ONLINE_AGENTSV2){
|
|
977
|
+
action = new ActionOnlineAgentV2();
|
|
978
|
+
}
|
|
979
|
+
```
|
|
980
|
+
|
|
981
|
+
with:
|
|
982
|
+
|
|
983
|
+
```ts
|
|
984
|
+
if(typeAction === TYPE_ACTION.ONLINE_AGENTSV2){
|
|
985
|
+
action = new ActionOnlineAgentV2();
|
|
986
|
+
}
|
|
987
|
+
if(typeAction === TYPE_ACTION.INVITE_HUMAN){
|
|
988
|
+
action = new ActionInviteHuman();
|
|
989
|
+
}
|
|
990
|
+
```
|
|
991
|
+
|
|
992
|
+
`CV/actions/list/cds-actions.module.ts` — after `import { CdsActionOnlineAgentsV2Component } from './cds-action-online-agents-v2/cds-action-online-agents.component';` add:
|
|
993
|
+
|
|
994
|
+
```ts
|
|
995
|
+
import { CdsActionInviteHumanComponent } from './cds-action-invite-human/cds-action-invite-human.component';
|
|
996
|
+
```
|
|
997
|
+
|
|
998
|
+
and add `CdsActionInviteHumanComponent,` right after `CdsActionOnlineAgentsV2Component,` in **both** the `declarations` and the `exports` arrays.
|
|
999
|
+
|
|
1000
|
+
`CV/cds-intent/cds-intent.component.html` — after the closing `</cds-action-online-agents-v2>` of the `TYPE_ACTION.ONLINE_AGENTSV2` case, add:
|
|
1001
|
+
|
|
1002
|
+
```html
|
|
1003
|
+
|
|
1004
|
+
<cds-action-invite-human *ngSwitchCase="TYPE_ACTION.INVITE_HUMAN"
|
|
1005
|
+
class="panel-response"
|
|
1006
|
+
[intentSelected]="intent"
|
|
1007
|
+
[action]="action"
|
|
1008
|
+
(updateAndSaveAction)="onUpdateAndSaveAction($event)">
|
|
1009
|
+
</cds-action-invite-human>
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
`CV/cds-panel-action-detail/cds-panel-action-detail.component.html` — after the closing `</cds-action-online-agents-v2>` of its `TYPE_ACTION.ONLINE_AGENTSV2` case, add:
|
|
1013
|
+
|
|
1014
|
+
```html
|
|
1015
|
+
|
|
1016
|
+
<cds-action-invite-human *ngSwitchCase="TYPE_ACTION.INVITE_HUMAN"
|
|
1017
|
+
class="panel-response"
|
|
1018
|
+
[intentSelected]="intentSelected"
|
|
1019
|
+
[action]="elementSelected"
|
|
1020
|
+
[previewMode]="false"
|
|
1021
|
+
(updateAndSaveAction)="onSaveIntent($event)"
|
|
1022
|
+
(onConnectorChange)="onConnectorChange($event.type, $event.fromId, $event.toId)">
|
|
1023
|
+
</cds-action-invite-human>
|
|
1024
|
+
```
|
|
1025
|
+
|
|
1026
|
+
`C/services/connector.service.ts` — replace:
|
|
1027
|
+
|
|
1028
|
+
```ts
|
|
1029
|
+
if(action._tdActionType === TYPE_ACTION.ONLINE_AGENTS || action._tdActionType === TYPE_ACTION.ONLINE_AGENTSV2){
|
|
1030
|
+
```
|
|
1031
|
+
|
|
1032
|
+
with:
|
|
1033
|
+
|
|
1034
|
+
```ts
|
|
1035
|
+
if(action._tdActionType === TYPE_ACTION.ONLINE_AGENTS || action._tdActionType === TYPE_ACTION.ONLINE_AGENTSV2 || action._tdActionType === TYPE_ACTION.INVITE_HUMAN){
|
|
1036
|
+
```
|
|
1037
|
+
|
|
1038
|
+
`C/services/icon.service.ts` — after the `assets/images/actions/online_agents.svg` registration block, add:
|
|
1039
|
+
|
|
1040
|
+
```ts
|
|
1041
|
+
this.matIconRegistry.addSvgIcon(
|
|
1042
|
+
'assets/images/actions/invite_human.svg',
|
|
1043
|
+
this.domSanitizer.bypassSecurityTrustResourceUrl('assets/images/actions/invite_human.svg')
|
|
1044
|
+
);
|
|
1045
|
+
```
|
|
1046
|
+
|
|
1047
|
+
Create `src/assets/images/actions/invite_human.svg`:
|
|
1048
|
+
|
|
1049
|
+
```svg
|
|
1050
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24" fill="currentColor"><path d="M0 0h24v24H0z" fill="none"/><path d="M15 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm-9-2V7H4v3H1v2h3v3h2v-3h3v-2H6zm9 4c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>
|
|
1051
|
+
```
|
|
1052
|
+
|
|
1053
|
+
- [ ] **Step 7: Add the translations**
|
|
1054
|
+
|
|
1055
|
+
In `src/assets/i18n/en.json`:
|
|
1056
|
+
|
|
1057
|
+
- in `CDSActionList.NAME`, after `"IfOnlineAgent": "If online agents",` add `"InviteHuman": "Invite human",`
|
|
1058
|
+
- in `CDSActionList.DOC`, before `"Condition": {` add:
|
|
1059
|
+
|
|
1060
|
+
```json
|
|
1061
|
+
"InviteHuman": {
|
|
1062
|
+
"TITLE": "Invite a human",
|
|
1063
|
+
"DESCRIPTION": "Adds a platform user to the conversation while the chatbot keeps running. Place it right before the block that asks the question (e.g. Advanced reply with buttons) to wait for the human answer. Available only in conversations started by a webhook.",
|
|
1064
|
+
"IMAGE": "",
|
|
1065
|
+
"VIDEO_URL": "",
|
|
1066
|
+
"DOC_URL": ""
|
|
1067
|
+
},
|
|
1068
|
+
```
|
|
1069
|
+
|
|
1070
|
+
- in `CDSCanvas`, after `"DevelopmentUrl":"Development Url",` add:
|
|
1071
|
+
|
|
1072
|
+
```json
|
|
1073
|
+
"InviteHumanDepartment": "Department (one available agent)",
|
|
1074
|
+
"InviteHumanConversationDepartment": "Conversation department",
|
|
1075
|
+
"InviteHumanMembers": "Members",
|
|
1076
|
+
"InviteHumanMembersPlaceholder": "Emails or user ids, comma separated (variables allowed)",
|
|
1077
|
+
"InviteHumanMembersDescription": "All listed members are invited. If none is valid, one available agent of the department is invited.",
|
|
1078
|
+
"InviteHumanInvited": "Invited",
|
|
1079
|
+
"InviteHumanNoHuman": "No human available",
|
|
1080
|
+
```
|
|
1081
|
+
|
|
1082
|
+
- [ ] **Step 8: Build and run the specs**
|
|
1083
|
+
|
|
1084
|
+
Run: `npx ng build`
|
|
1085
|
+
Expected: build completes without errors.
|
|
1086
|
+
|
|
1087
|
+
Run: `npx ng test --watch=false --browsers=ChromeHeadless --include=src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-invite-human/cds-action-invite-human.component.spec.ts --include=src/app/chatbot-design-studio/utils-webhook.spec.ts --include=src/app/chatbot-design-studio/services/webhook-service.service.spec.ts`
|
|
1088
|
+
Expected: PASS.
|
|
1089
|
+
|
|
1090
|
+
- [ ] **Step 9: Manual verification**
|
|
1091
|
+
|
|
1092
|
+
1. In a `chatbot` subtype flow, "Invite human" appears in the add-action menu (Most used); in a `webhook` subtype flow it does not.
|
|
1093
|
+
2. Add it to a block: the preview shows "Conversation department", "Invited" and "No human available" connectors.
|
|
1094
|
+
3. Select a department, type `ops@acme.it, {{oncall}}` (use the variable picker for `oncall`), connect both outputs, save, reload the flow: values and connectors are restored.
|
|
1095
|
+
4. Export the flow JSON: the action has `_tdActionType: "invite_human"`, `departmentId`, `members`, `trueIntent`, `falseIntent`.
|
|
1096
|
+
|
|
1097
|
+
- [ ] **Step 10: Commit**
|
|
1098
|
+
|
|
1099
|
+
```bash
|
|
1100
|
+
git add src/app/models/action-model.ts src/app/chatbot-design-studio/utils-actions.ts src/app/chatbot-design-studio/services/intent.service.ts src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-invite-human src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-actions.module.ts src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.html src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-action-detail/cds-panel-action-detail.component.html src/app/chatbot-design-studio/services/connector.service.ts src/app/chatbot-design-studio/services/icon.service.ts src/assets/images/actions/invite_human.svg src/assets/i18n/en.json
|
|
1101
|
+
git commit -m "feat(actions): add Invite human action for conversational chatbots
|
|
1102
|
+
|
|
1103
|
+
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>"
|
|
1104
|
+
```
|
|
1105
|
+
|
|
1106
|
+
---
|
|
1107
|
+
|
|
1108
|
+
### Task 4: Test the webhook start from Design Studio
|
|
1109
|
+
|
|
1110
|
+
**Files:**
|
|
1111
|
+
- Modify: `C/services/controller.service.ts` (after `public isTestItOutPlaying$ = this.testItOutPlaying.asObservable();` `:31`)
|
|
1112
|
+
- Modify: `C/services/intent.service.ts` (after `BSTestItOut = new BehaviorSubject<Intent>(null);` `:37`)
|
|
1113
|
+
- Modify: `CV/cds-panel-intent-detail/cds-panel-intent-detail.component.ts` / `.html` (constructor, start webhook section from Task 2)
|
|
1114
|
+
- Modify: `C/cds-dashboard/cds-header/cds-header.component.ts` (fields near `isPlaying` `:70`, `ngOnDestroy`, `setSubscriptions` `:158-167`, `onCloseTestItOut` `:416-424`, new method)
|
|
1115
|
+
- Modify: `C/cds-dashboard/cds-header/cds-header.component.html:110`
|
|
1116
|
+
- Modify: `CV/cds-canvas.component.ts:1538`
|
|
1117
|
+
- Modify: `CV/cds-intent/cds-intent.component.ts:196`, `:198`, `:218`
|
|
1118
|
+
- Modify: `src/assets/i18n/en.json` (`CDSCanvas`)
|
|
1119
|
+
|
|
1120
|
+
**Interfaces:**
|
|
1121
|
+
- Consumes: `isStartWebhookActive` (Task 1); start webhook section (Task 2); existing header methods `getToken(request_id)`, `stopWebhook()`, `openTestSiteInPopupWindow()`; `WebhookService.getWebhook`, `preloadWebhook`; `LogService.initialize(request_id)`, `LogService.starterLog(mqtt_token, request_id)`.
|
|
1122
|
+
- Produces: `ControllerService.webhookStartTestRequested$: Observable<void>`, `ControllerService.requestWebhookStartTest(): void`; `IntentService.webhookStartTest: boolean`; header `isWebhookStartTest: boolean`, `onOpenWebhookStartTest(): Promise<void>`.
|
|
1123
|
+
|
|
1124
|
+
- [ ] **Step 1: Add the request channel and the flag**
|
|
1125
|
+
|
|
1126
|
+
In `C/services/controller.service.ts`, after `public isTestItOutPlaying$ = this.testItOutPlaying.asObservable();` add:
|
|
1127
|
+
|
|
1128
|
+
```ts
|
|
1129
|
+
|
|
1130
|
+
private webhookStartTestSource = new Subject<void>();
|
|
1131
|
+
public webhookStartTestRequested$ = this.webhookStartTestSource.asObservable();
|
|
1132
|
+
|
|
1133
|
+
public requestWebhookStartTest(){
|
|
1134
|
+
this.webhookStartTestSource.next();
|
|
1135
|
+
}
|
|
1136
|
+
```
|
|
1137
|
+
|
|
1138
|
+
In `C/services/intent.service.ts`, after `BSTestItOut = new BehaviorSubject<Intent>(null);` add:
|
|
1139
|
+
|
|
1140
|
+
```ts
|
|
1141
|
+
webhookStartTest: boolean = false;
|
|
1142
|
+
```
|
|
1143
|
+
|
|
1144
|
+
- [ ] **Step 2: Add the test button to the start webhook section**
|
|
1145
|
+
|
|
1146
|
+
In `cds-panel-intent-detail.component.ts` add the import:
|
|
1147
|
+
|
|
1148
|
+
```ts
|
|
1149
|
+
import { ControllerService } from 'src/app/chatbot-design-studio/services/controller.service';
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
add `private readonly controllerService: ControllerService` as a new constructor parameter (after `private readonly connectorService: ConnectorService`), and add the method:
|
|
1153
|
+
|
|
1154
|
+
```ts
|
|
1155
|
+
onTestStartWebhook(){
|
|
1156
|
+
this.controllerService.requestWebhookStartTest();
|
|
1157
|
+
}
|
|
1158
|
+
```
|
|
1159
|
+
|
|
1160
|
+
In `cds-panel-intent-detail.component.html`, inside the start webhook section, replace:
|
|
1161
|
+
|
|
1162
|
+
```html
|
|
1163
|
+
<div class="webhook-buttons">
|
|
1164
|
+
<button type="button" class="btn btn-primary cds-blue-button" (click)="onRegenerateWebhook()">{{ 'Regenerate' | translate }}</button>
|
|
1165
|
+
</div>
|
|
1166
|
+
```
|
|
1167
|
+
|
|
1168
|
+
with:
|
|
1169
|
+
|
|
1170
|
+
```html
|
|
1171
|
+
<div class="webhook-buttons">
|
|
1172
|
+
<button type="button" class="btn btn-primary cds-blue-button" (click)="onTestStartWebhook()">{{ 'CDSCanvas.StartWebhookTest' | translate }}</button>
|
|
1173
|
+
<button type="button" class="btn btn-primary cds-blue-button" (click)="onRegenerateWebhook()">{{ 'Regenerate' | translate }}</button>
|
|
1174
|
+
</div>
|
|
1175
|
+
```
|
|
1176
|
+
|
|
1177
|
+
In `src/assets/i18n/en.json`, `CDSCanvas`, after `"StartWebhookError": "Unable to update the webhook",` add:
|
|
1178
|
+
|
|
1179
|
+
```json
|
|
1180
|
+
"StartWebhookTest": "Test webhook start",
|
|
1181
|
+
```
|
|
1182
|
+
|
|
1183
|
+
- [ ] **Step 3: Run the test from the header**
|
|
1184
|
+
|
|
1185
|
+
In `cds-header.component.ts`:
|
|
1186
|
+
|
|
1187
|
+
Add the import:
|
|
1188
|
+
|
|
1189
|
+
```ts
|
|
1190
|
+
import { isStartWebhookActive } from '../../utils-webhook';
|
|
1191
|
+
```
|
|
1192
|
+
|
|
1193
|
+
Add fields after `isPlaying:boolean = false;`:
|
|
1194
|
+
|
|
1195
|
+
```ts
|
|
1196
|
+
isWebhookStartTest: boolean = false;
|
|
1197
|
+
private subscriptionWebhookStartTest: Subscription;
|
|
1198
|
+
```
|
|
1199
|
+
|
|
1200
|
+
In `ngOnDestroy`, after `this.subscriptionIsSavingVisible?.unsubscribe();` add:
|
|
1201
|
+
|
|
1202
|
+
```ts
|
|
1203
|
+
this.subscriptionWebhookStartTest?.unsubscribe();
|
|
1204
|
+
```
|
|
1205
|
+
|
|
1206
|
+
In `setSubscriptions()`, before `/** SUBSCRIBE TO THE GLOBAL SAVING STATE */` add:
|
|
1207
|
+
|
|
1208
|
+
```ts
|
|
1209
|
+
/** SUBSCRIBE TO WEBHOOK START TEST REQUESTS (start block panel) */
|
|
1210
|
+
this.subscriptionWebhookStartTest = this.controllerService.webhookStartTestRequested$.subscribe(() => {
|
|
1211
|
+
this.onOpenWebhookStartTest();
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
```
|
|
1215
|
+
|
|
1216
|
+
Replace:
|
|
1217
|
+
|
|
1218
|
+
```ts
|
|
1219
|
+
onCloseTestItOut(){
|
|
1220
|
+
if(this.isWebhook){
|
|
1221
|
+
this.stopWebhook();
|
|
1222
|
+
}
|
|
1223
|
+
```
|
|
1224
|
+
|
|
1225
|
+
with:
|
|
1226
|
+
|
|
1227
|
+
```ts
|
|
1228
|
+
onCloseTestItOut(){
|
|
1229
|
+
if(this.isWebhook || this.isWebhookStartTest){
|
|
1230
|
+
this.stopWebhook();
|
|
1231
|
+
}
|
|
1232
|
+
this.isWebhookStartTest = false;
|
|
1233
|
+
this.intentService.webhookStartTest = false;
|
|
1234
|
+
```
|
|
1235
|
+
|
|
1236
|
+
Add the new method right after `onCloseTestItOut()`:
|
|
1237
|
+
|
|
1238
|
+
```ts
|
|
1239
|
+
async onOpenWebhookStartTest(){
|
|
1240
|
+
if (this.isPlaying) {
|
|
1241
|
+
this.onCloseTestItOut();
|
|
1242
|
+
}
|
|
1243
|
+
this.serverBaseURL = this.appConfigService.getConfig().apiUrl;
|
|
1244
|
+
const chatbot_id = this.dashboardService.id_faq_kb;
|
|
1245
|
+
try {
|
|
1246
|
+
const webhook = await lastValueFrom(this.webhookService.getWebhook(chatbot_id));
|
|
1247
|
+
if (!isStartWebhookActive(webhook)) {
|
|
1248
|
+
this.logger.warn("[CDS-header] start webhook not active for chatbot_id:", chatbot_id);
|
|
1249
|
+
return;
|
|
1250
|
+
}
|
|
1251
|
+
this.webhookId = webhook.webhook_id;
|
|
1252
|
+
this.webhookUrl = `${this.serverBaseURL}webhook/${webhook.webhook_id}`;
|
|
1253
|
+
const preload = await lastValueFrom(this.webhookService.preloadWebhook(this.webhookId));
|
|
1254
|
+
if (!preload?.request_id) {
|
|
1255
|
+
this.logger.warn("[CDS-header] preload request_id not found");
|
|
1256
|
+
return;
|
|
1257
|
+
}
|
|
1258
|
+
this.logService.initialize(null);
|
|
1259
|
+
const tokenResp = await this.getToken(preload.request_id);
|
|
1260
|
+
if (!tokenResp) {
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
this.isWebhookStartTest = true;
|
|
1264
|
+
this.intentService.webhookStartTest = true;
|
|
1265
|
+
this.logService.starterLog(tokenResp.token || null, tokenResp.request_id || preload.request_id);
|
|
1266
|
+
this.openTestSiteInPopupWindow();
|
|
1267
|
+
this.isPlaying = true;
|
|
1268
|
+
} catch (error) {
|
|
1269
|
+
this.logger.error("[CDS-header] onOpenWebhookStartTest error:", error);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
```
|
|
1273
|
+
|
|
1274
|
+
In `cds-header.component.html`, replace:
|
|
1275
|
+
|
|
1276
|
+
```html
|
|
1277
|
+
<div *ngIf="webhookUrl && isPlaying && isWebhook" class="btn-group box-url"
|
|
1278
|
+
```
|
|
1279
|
+
|
|
1280
|
+
with:
|
|
1281
|
+
|
|
1282
|
+
```html
|
|
1283
|
+
<div *ngIf="webhookUrl && isPlaying && (isWebhook || isWebhookStartTest)" class="btn-group box-url"
|
|
1284
|
+
```
|
|
1285
|
+
|
|
1286
|
+
- [ ] **Step 4: Don't open the draft widget during a webhook start test**
|
|
1287
|
+
|
|
1288
|
+
In `CV/cds-canvas.component.ts`, in `onTestItOut`, replace:
|
|
1289
|
+
|
|
1290
|
+
```ts
|
|
1291
|
+
if(subtype !== TYPE_CHATBOT.WEBHOOK && subtype != TYPE_CHATBOT.COPILOT){
|
|
1292
|
+
```
|
|
1293
|
+
|
|
1294
|
+
with:
|
|
1295
|
+
|
|
1296
|
+
```ts
|
|
1297
|
+
if(subtype !== TYPE_CHATBOT.WEBHOOK && subtype != TYPE_CHATBOT.COPILOT && !this.intentService.webhookStartTest){
|
|
1298
|
+
```
|
|
1299
|
+
|
|
1300
|
+
- [ ] **Step 5: Highlight the start block during a webhook start test**
|
|
1301
|
+
|
|
1302
|
+
In `CV/cds-intent/cds-intent.component.ts` (`TYPE_INTENT_NAME` is already imported from `src/app/chatbot-design-studio/utils` at line 15), replace the three occurrences (lines 196, 198, 218) of:
|
|
1303
|
+
|
|
1304
|
+
```ts
|
|
1305
|
+
this.intent?.intent_display_name === TYPE_CHATBOT.WEBHOOK
|
|
1306
|
+
```
|
|
1307
|
+
|
|
1308
|
+
with:
|
|
1309
|
+
|
|
1310
|
+
```ts
|
|
1311
|
+
this.isLiveStartBlock()
|
|
1312
|
+
```
|
|
1313
|
+
|
|
1314
|
+
and add this method to the component class right before `ngOnDestroy() {` (line 539):
|
|
1315
|
+
|
|
1316
|
+
```ts
|
|
1317
|
+
/** Blocks that get the "live start" highlight: the webhook block, or the start block during a webhook start test */
|
|
1318
|
+
private isLiveStartBlock(): boolean {
|
|
1319
|
+
const name = this.intent?.intent_display_name;
|
|
1320
|
+
return name === TYPE_CHATBOT.WEBHOOK || (this.intentService.webhookStartTest === true && name === TYPE_INTENT_NAME.START);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
```
|
|
1324
|
+
|
|
1325
|
+
- [ ] **Step 6: Build and run all new specs**
|
|
1326
|
+
|
|
1327
|
+
Run: `npx ng build`
|
|
1328
|
+
Expected: build completes without errors.
|
|
1329
|
+
|
|
1330
|
+
Run: `npx ng test --watch=false --browsers=ChromeHeadless --include=src/app/chatbot-design-studio/utils-webhook.spec.ts --include=src/app/chatbot-design-studio/services/webhook-service.service.spec.ts --include=src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-invite-human/cds-action-invite-human.component.spec.ts`
|
|
1331
|
+
Expected: PASS.
|
|
1332
|
+
|
|
1333
|
+
- [ ] **Step 7: Manual verification (local DS + server + tybot from their plans)**
|
|
1334
|
+
|
|
1335
|
+
1. Enable the start webhook, click **Test webhook start**: the header shows the dev URL box and the stop button; the draft widget does **not** open; the logs panel opens; the start block is highlighted.
|
|
1336
|
+
2. `curl -X POST "<dev URL>" -H 'Content-Type: application/json' -d '{"alert":"KubePodCrashLooping"}'` → `202 {request_id}` equal to the preloaded id; the logs panel shows the flow run.
|
|
1337
|
+
3. Click stop: `DELETE /webhooks/preload/<webhook_id>` is sent; calling the dev URL again returns 422.
|
|
1338
|
+
Each dev call consumes the preload: click **Test webhook start** again before another call.
|
|
1339
|
+
4. Click the normal play button on the same chatbot: the draft widget opens as before.
|
|
1340
|
+
5. Open an automation (subtype `webhook`) bot and use play: behaviour unchanged.
|
|
1341
|
+
|
|
1342
|
+
- [ ] **Step 8: Commit**
|
|
1343
|
+
|
|
1344
|
+
```bash
|
|
1345
|
+
git add src/app/chatbot-design-studio/services/controller.service.ts src/app/chatbot-design-studio/services/intent.service.ts src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-intent-detail/cds-panel-intent-detail.component.ts src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-intent-detail/cds-panel-intent-detail.component.html src/app/chatbot-design-studio/cds-dashboard/cds-header/cds-header.component.ts src/app/chatbot-design-studio/cds-dashboard/cds-header/cds-header.component.html src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts src/assets/i18n/en.json
|
|
1346
|
+
git commit -m "feat(test-it-out): test a webhook start with the dev URL and flow logs
|
|
1347
|
+
|
|
1348
|
+
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>"
|
|
1349
|
+
```
|