Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions components/cogmento/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import cogmento from "../../cogmento.app.mjs";

export default {
key: "cogmento-create-contact",
name: "Create Contact",
description: "Create a new contact in Cogmento CRM. [See the documentation](https://api.cogmento.com/static/swagger/index.html#/Contacts/post_contacts_)",
version: "0.0.1",
type: "action",
props: {
cogmento,
firstName: {
type: "string",
label: "First Name",
description: "First name of the contact",
},
lastName: {
type: "string",
label: "Last Name",
description: "Last name of the contact",
},
email: {
type: "string",
label: "Email",
description: "Email address of the contact",
optional: true,
},
phone: {
type: "string",
label: "Phone",
description: "Phone number of the contact",
optional: true,
},
description: {
type: "string",
label: "Description",
description: "Description of the contact",
optional: true,
},
tags: {
type: "string[]",
label: "Tags",
description: "Array of tags associated with the contact",
optional: true,
},
doNotCall: {
type: "boolean",
label: "Do Not Call",
description: "Set to `true` to mark the contact as Do Not Call",
optional: true,
},
doNotText: {
type: "boolean",
label: "Do Not Text",
description: "Set to `true` to mark the contact as Do Not Text",
optional: true,
},
doNotEmail: {
type: "boolean",
label: "Do Not Email",
description: "Set to `true` to mark the contact as Do Not Email",
optional: true,
},
},
async run({ $ }) {
const channels = [];
if (this.email) {
channels.push({
channel_type: "Email",
value: this.email,
});
}
if (this.phone) {
channels.push({
channel_type: "Phone",
value: this.phone,
});
}

const response = await this.cogmento.createContact({
$,
data: {
first_name: this.firstName,
last_name: this.lastName,
channels,
description: this.description,
tags: this.tags,
do_not_call: this.doNotCall,
do_not_text: this.doNotText,
do_not_email: this.doNotEmail,
},
});
$.export("$summary", `Successfully created contact: ${this.firstName} ${this.lastName}`);
return response;
},
};
75 changes: 75 additions & 0 deletions components/cogmento/actions/create-deal/create-deal.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import cogmento from "../../cogmento.app.mjs";

export default {
key: "cogmento-create-deal",
name: "Create Deal",
description: "Create a new deal in Cogmento CRM. [See the documentation](https://api.cogmento.com/static/swagger/index.html#/Deals/post_deals_)",
version: "0.0.1",
type: "action",
props: {
cogmento,
title: {
type: "string",
label: "Title",
description: "The title of the deal",
},
description: {
type: "string",
label: "Description",
description: "A description of the deal",
optional: true,
},
assigneeIds: {
propDefinition: [
cogmento,
"userIds",
],
optional: true,
},
tags: {
type: "string[]",
label: "Tags",
description: "Array of tags associated with the deal",
optional: true,
},
closeDate: {
type: "string",
label: "Close Date",
description: "The date the deal was completed (format: YYYY-MM-DD)",
optional: true,
},
productIds: {
propDefinition: [
cogmento,
"productIds",
],
optional: true,
},
amount: {
type: "string",
label: "Amount",
description: "The final deal value",
optional: true,
},
},
async run({ $ }) {
const response = await this.cogmento.createDeal({
$,
data: {
title: this.title,
description: this.description,
assigned_to: this.assigneeIds?.map((id) => ({
id,
})) || undefined,
tags: this.tags,
close_date: this.closeDate,
products: this.productIds?.map((id) => ({
id,
})) || undefined,
amount: this.amount && +this.amount,
},
});
$.export("$summary", `Successfully created deal: ${this.title}`);
return response;
},
};
72 changes: 72 additions & 0 deletions components/cogmento/actions/create-task/create-task.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import cogmento from "../../cogmento.app.mjs";

export default {
key: "cogmento-create-task",
name: "Create Task",
description: "Create a new task in Cogmento CRM. [See the documentation](https://api.cogmento.com/static/swagger/index.html#/Tasks/post_tasks_)",
version: "0.0.1",
type: "action",
props: {
cogmento,
title: {
type: "string",
label: "Title",
description: "The title of the task",
},
description: {
type: "string",
label: "Description",
description: "A description of the task",
optional: true,
},
dueDate: {
type: "string",
label: "Due Date",
description: "The task's deadline(format: YYYY-MM-DD)",
optional: true,
},
assigneeIds: {
propDefinition: [
cogmento,
"userIds",
],
description: "An array of user IDs to assign to the task",
optional: true,
},
dealId: {
propDefinition: [
cogmento,
"dealId",
],
optional: true,
},
contactId: {
propDefinition: [
cogmento,
"contactId",
],
optional: true,
},
},
async run({ $ }) {
const response = await this.cogmento.createTask({
$,
data: {
title: this.title,
description: this.description,
due_date: this.dueDate,
assigned_to: this.assigneeIds?.map((id) => ({
id,
})) || undefined,
deal: this.dealId && {
id: this.dealId,
},
contact: this.contactId && {
id: this.contactId,
},
},
});
$.export("$summary", `Successfully created task: ${this.title}`);
return response;
},
};
Loading
Loading