Skip to content

Commit 19ca422

Browse files
committed
Add TaskId in conversation.
1 parent e1e7593 commit 19ca422

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

src/lib/helpers/types.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,18 @@
166166
* @property {string} planner
167167
*/
168168

169+
/**
170+
* @typedef {Object} MessageConfig
171+
* @property {string} [taskId] - Optional task id.
172+
*/
173+
169174
/**
170175
* @typedef {Object} ConversationFilter
171176
* @property {Pagination} pager - Pagination
172177
* @property {string} [agentId] - The agent id.
173178
* @property {string} [channel] - The conversation channel.
174179
* @property {string} [status] - The conversation status.
180+
* @property {string} [taskId] - The task id.
175181
*/
176182

177183
/**
@@ -182,6 +188,7 @@
182188
* @property {string} agent_id - The conversation agent id.
183189
* @property {string} agent_name - The conversation entry agent name.
184190
* @property {string} channel - The conversation status.
191+
* @property {string} [task_id] - Optional task id.
185192
* @property {string} status - The conversation status.
186193
* @property {Object[]} states - The conversation states.
187194
* @property {Date} updated_time - The conversation updated time.

src/lib/services/conversation-service.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import { conversationUserStateStore } from '$lib/helpers/store.js';
66
/**
77
* New conversation
88
* @param {string} agentId
9+
* @param {Promise<import('$types').MessageConfig>} [config]
910
* @returns {Promise<import('$types').ConversationModel>}
1011
*/
11-
export async function newConversation(agentId) {
12+
export async function newConversation(agentId, config) {
1213
let url = replaceUrl(endpoints.conversationInitUrl, {agentId: agentId});
13-
const response = await axios.post(url, {});
14+
const response = await axios.post(url, config ?? {});
1415
return response.data;
1516
}
1617

src/routes/page/conversation/+page.svelte

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,33 +174,38 @@
174174
</CardBody>
175175
<CardBody class="border-bottom">
176176
<Row class="g-3">
177-
<Col xxl="4" lg="6">
177+
<Col lg="4">
178178
<Input
179179
type="search"
180180
class="form-control"
181181
id="searchTableList"
182182
placeholder="Search for ..."
183183
/>
184184
</Col>
185-
<Col xxl="2" lg="6">
185+
<Col lg="2">
186+
<select class="form-select" id="idTask" bind:value={filter.taskId}>
187+
<option value={null}>Task</option>
188+
</select>
189+
</Col>
190+
<Col lg="1">
186191
<select class="form-select" id="idStatus" bind:value={filter.status}>
187192
<option value={null}>Status</option>
188193
<option value="open">Active</option>
189194
<option value="closed">Completed</option>
190195
</select>
191196
</Col>
192-
<Col xxl="2" lg="4">
197+
<Col lg="2">
193198
<select class="form-select" id="idType" bind:value={filter.channel}>
194199
<option value={null}>Select Channel</option>
195200
<option value="webchat">Live Chat</option>
196201
<option value="phone">Phone</option>
197202
<option value="email">Email</option>
198203
</select>
199204
</Col>
200-
<Col xxl="2" lg="4">
205+
<Col lg="2">
201206
<Input type="date" class="form-control" />
202207
</Col>
203-
<Col xxl="2" lg="4">
208+
<Col lg="1">
204209
<Button type="button" color="secondary" class="btn-soft-secondary w-100">
205210
<i class="mdi mdi-filter-outline align-middle" /> Filter
206211
</Button>

src/routes/page/task/[taskId]/execution-flow.svelte

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@
110110
*/
111111
function renderMessageNode(message, response) {
112112
let posX = lastPosX + nodeSpaceX, posY = lastPosY + nodeSpaceY;
113-
let html = `${message}`;
113+
let html = `<div class=''>${message}</div>`;
114114
if (response.data) {
115-
html += `<img src=${response.data} alt="" width="165px"/>`
115+
html += `<img src=${response.data} alt="" width="215px"/>`
116116
}
117117
html += `<div class="bg-info mt-1 mb-1 p-1 rounded">${response.text}</div>`;
118118
@@ -138,7 +138,7 @@
138138
renderTaskNode();
139139
140140
// new conversation
141-
const conversation = await newConversation(task.agent_id);
141+
const conversation = await newConversation(task.agent_id, {taskId: task.id});
142142
conversationStore.set(conversation);
143143
renderConversationNode(conversation);
144144
@@ -152,7 +152,8 @@
152152
renderTaskNode();
153153
154154
// new conversation
155-
const conversation = await newConversation(task.direct_agent_id);
155+
const conversation = await newConversation(task.direct_agent_id, {taskId: task.id});
156+
conversation.task_id = task.id;
156157
conversationStore.set(conversation);
157158
renderConversationNode(conversation);
158159

0 commit comments

Comments
 (0)