Skip to content

Commit 9391348

Browse files
committed
insertchat
1 parent fb4189f commit 9391348

File tree

9 files changed

+315
-212
lines changed

9 files changed

+315
-212
lines changed

components/insertchat/actions/create-lead/create-lead.mjs

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,75 @@ import insertchat from "../../insertchat.app.mjs";
33
export default {
44
key: "insertchat-create-lead",
55
name: "Create Lead",
6-
description: "Creates a new lead within Insertchat.",
7-
version: "0.0.{{ts}}",
6+
description: "Creates a new lead within Insertchat. [See the documentation](https://www.postman.com/gold-star-239225/insertchat/request/uiugp1c/create-a-lead)",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
insertchat,
11-
leadContactInfo: {
11+
chatbotId: {
1212
propDefinition: [
1313
insertchat,
14-
"leadContactInfo",
14+
"chatbotId",
1515
],
1616
},
17-
leadStatus: {
18-
propDefinition: [
19-
insertchat,
20-
"leadStatus",
21-
],
17+
firstName: {
18+
type: "string",
19+
label: "First Name",
20+
description: "First name of the lead",
21+
optional: true,
22+
},
23+
lastName: {
24+
type: "string",
25+
label: "Last Name",
26+
description: "Last name of the lead",
27+
optional: true,
28+
},
29+
email: {
30+
type: "string",
31+
label: "Email",
32+
description: "Email address of the lead",
33+
optional: true,
34+
},
35+
phone: {
36+
type: "string",
37+
label: "Phone",
38+
description: "Phone number of the lead",
39+
optional: true,
40+
},
41+
address: {
42+
type: "string",
43+
label: "Address",
44+
description: "Address of the lead",
45+
optional: true,
46+
},
47+
website: {
48+
type: "string",
49+
label: "Website",
50+
description: "Website of the lead",
51+
optional: true,
52+
},
53+
company: {
54+
type: "string",
55+
label: "Company",
56+
description: "Company of the lead",
2257
optional: true,
2358
},
2459
},
2560
async run({ $ }) {
26-
const response = await this.insertchat.createNewLead(this.leadContactInfo, this.leadStatus);
27-
$.export("$summary", `Created lead with ID: ${response.id}`);
61+
const response = await this.insertchat.createLead({
62+
$,
63+
data: {
64+
widget_uid: this.chatbotId,
65+
first_name: this.firstName,
66+
last_name: this.lastName,
67+
email: this.email,
68+
phone: this.phone,
69+
address: this.address,
70+
website: this.website,
71+
company: this.company,
72+
},
73+
});
74+
$.export("$summary", `Created lead with ID: ${response.uid}`);
2875
return response;
2976
},
3077
};

components/insertchat/actions/delete-lead/delete-lead.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import insertchat from "../../insertchat.app.mjs";
33
export default {
44
key: "insertchat-delete-lead",
55
name: "Delete Lead",
6-
description: "Deletes an existing lead from InsertChat. [See the documentation](https://docs.insertchat.com/)",
6+
description: "Deletes an existing lead from InsertChat. [See the documentation](https://www.postman.com/gold-star-239225/insertchat/request/2vgc20j/delete-a-lead)",
77
version: "0.0.1",
88
type: "action",
99
props: {
@@ -16,7 +16,10 @@ export default {
1616
},
1717
},
1818
async run({ $ }) {
19-
const response = await this.insertchat.deleteLead(this.leadId);
19+
const response = await this.insertchat.deleteLead({
20+
$,
21+
leadId: this.leadId,
22+
});
2023
$.export("$summary", `Successfully deleted lead with ID: ${this.leadId}`);
2124
return response;
2225
},

components/insertchat/actions/push-message-existing-chat/push-message-existing-chat.mjs

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,53 @@ import insertchat from "../../insertchat.app.mjs";
33
export default {
44
key: "insertchat-push-message-existing-chat",
55
name: "Push Message to Existing Chat",
6-
description: "Pushes a new message into an existing chat session in InsertChat",
7-
version: "0.0.{{ts}}",
6+
description: "Pushes a new message into an existing chat session in InsertChat. [See the documentation](https://www.postman.com/gold-star-239225/insertchat/request/me7mcwa/push-a-message-into-a-chat-session)",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
insertchat,
11-
chatSessionId: {
11+
chatbotId: {
1212
propDefinition: [
1313
insertchat,
14-
"chatSessionId",
14+
"chatbotId",
1515
],
1616
},
17-
messageContent: {
17+
chatSessionId: {
1818
propDefinition: [
1919
insertchat,
20-
"messageContent",
20+
"chatSessionId",
21+
(c) => ({
22+
chatbotId: c.chatbotId,
23+
}),
2124
],
2225
},
23-
messageSender: {
24-
propDefinition: [
25-
insertchat,
26-
"messageSender",
26+
role: {
27+
type: "string",
28+
label: "Role",
29+
description: "Role to send message as",
30+
options: [
31+
"user",
32+
"assistant",
2733
],
28-
optional: true,
34+
},
35+
message: {
36+
type: "string",
37+
label: "Message Content",
38+
description: "The content of the message to be pushed into the chat session",
2939
},
3040
},
31-
async run({ $ }) {
32-
const response = await this.insertchat.pushMessage(
33-
this.chatSessionId,
34-
this.messageContent,
35-
this.messageSender,
36-
);
41+
run({ $ }) {
42+
// method works, but times out if we await the response
43+
this.insertchat.pushMessage({
44+
$,
45+
data: new URLSearchParams({
46+
widget_uid: this.chatbotId,
47+
chat_uid: this.chatSessionId,
48+
role: this.role,
49+
input: this.message,
50+
}),
51+
});
3752
$.export("$summary", `Successfully pushed message to chat session ${this.chatSessionId}`);
38-
return response;
53+
// nothing to return
3954
},
4055
};

0 commit comments

Comments
 (0)