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
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import belco from "../../belco.app.mjs";

export default {
key: "belco-add-note-to-conversation",
name: "Add Note to Conversation",
description: "Add a note to a conversation specified by ID. [See the documentation](https://developers.belco.io/reference/put_conversations-conversationid-addnote)",
version: "0.0.1",
type: "action",
props: {
belco,
conversationId: {
propDefinition: [
belco,
"conversationId",
],
},
body: {
type: "string",
label: "Body",
description: "The note body",
},
},
async run({ $ }) {
const response = await this.belco.addNoteToConversation({
$,
conversationId: this.conversationId,
data: {
body: this.body,
},
});

$.export("$summary", `Added note to conversation successfully: ${this.conversationId}`);
return response;
},
};
32 changes: 32 additions & 0 deletions components/belco/actions/close-conversation/close-conversation.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import belco from "../../belco.app.mjs";

export default {
key: "belco-close-conversation",
name: "Close Conversation",
description: "Close a conversation specified by ID. [See the documentation](https://developers.belco.io/reference/put_conversations-conversationid-close)",
version: "0.0.1",
type: "action",
props: {
belco,
conversationId: {
propDefinition: [
belco,
"conversationId",
() => ({
excludeStatus: [
"closed",
],
}),
],
},
},
async run({ $ }) {
const response = await this.belco.closeConversation({
$,
conversationId: this.conversationId,
});

$.export("$summary", `Closed conversation successfully: ${this.conversationId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import belco from "../../belco.app.mjs";

export default {
key: "belco-create-conversation",
name: "Create Conversation",
description: "Create a conversation from Belco. [See the documentation](https://developers.belco.io/reference/post_conversations)",
version: "0.0.1",
type: "action",
props: {
belco,
shopId: {
propDefinition: [
belco,
"shopId",
],
},
channel: {
propDefinition: [
belco,
"channel",
],
},
type: {
propDefinition: [
belco,
"type",
],
},
fromType: {
propDefinition: [
belco,
"fromType",
],
},
from: {
propDefinition: [
belco,
"from",
({
fromType, shopId,
}) => ({
fromType,
shopId,
}),
],
},
to: {
propDefinition: [
belco,
"to",
({
toType, shopId,
}) => ({
toType,
shopId,
}),
],
},
subject: {
propDefinition: [
belco,
"subject",
],
},
body: {
propDefinition: [
belco,
"body",
],
},
},
async run({ $ }) {
const response = await this.belco.createConversation({
$,
data: {
shopId: this.shopId,
channel: this.channel,
type: this.type,
from: {
type: this.fromType,
_id: this.from,
},
to: {
type: "contact",
_id: this.to,
},
subject: this.subject,
body: this.body,
},
});

$.export("$summary", `New conversation created successfully with ID: ${response._id}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import belco from "../../belco.app.mjs";

export default {
key: "belco-list-all-conversations",
name: "List All Conversations",
description: "Get a list of conversations from Belco. [See the documentation](https://developers.belco.io/reference/get_conversations)",
version: "0.0.1",
type: "action",
props: {
belco,
limit: {
type: "integer",
label: "Limit",
description: "Maximum number of conversations to retrieve",
default: 50,
min: 1,
max: 100,
},
skip: {
type: "integer",
label: "Skip",
description: "Number of conversations to skip",
default: 0,
min: 0,
},
},
async run({ $ }) {
const params = {
limit: this.limit,
skip: this.skip,
};

const response = await this.belco.listConversations({
$,
params,
});

$.export("$summary", `Retrieved ${response.conversations.length} conversations`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import belco from "../../belco.app.mjs";

export default {
key: "belco-reopen-conversation",
name: "Reopen Conversation",
description: "Reopen a conversation specified by ID. [See the documentation](https://developers.belco.io/reference/put_conversations-conversationid-open)",
version: "0.0.1",
type: "action",
props: {
belco,
conversationId: {
propDefinition: [
belco,
"conversationId",
() => ({
includeStatus: [
"closed",
],
}),
],
},
},
async run({ $ }) {
const response = await this.belco.reopenConversation({
$,
conversationId: this.conversationId,
});

$.export("$summary", `Reopened conversation successfully: ${this.conversationId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import belco from "../../belco.app.mjs";

export default {
key: "belco-reply-to-conversation",
name: "Reply to Conversation",
description: "Reply to a conversation specified by ID. [See the documentation](https://developers.belco.io/reference/put_conversations-conversationid-reply)",
version: "0.0.1",
type: "action",
props: {
belco,
conversationId: {
propDefinition: [
belco,
"conversationId",
],
},
body: {
type: "string",
label: "Body",
description: "The reply message body",
},
},
async run({ $ }) {
const response = await this.belco.replyToConversation({
$,
conversationId: this.conversationId,
data: {
body: this.body,
},
});

$.export("$summary", `Replied to conversation successfully: ${this.conversationId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import belco from "../../belco.app.mjs";

export default {
key: "belco-retrieve-conversation",
name: "Retrieve Conversation",
description: "Retrieve a conversation specified by ID. [See the documentation](https://developers.belco.io/reference/get_conversations-conversationid)",
version: "0.0.1",
type: "action",
props: {
belco,
conversationId: {
propDefinition: [
belco,
"conversationId",
],
},
},
async run({ $ }) {
const response = await this.belco.getConversation({
$,
conversationId: this.conversationId,
});

$.export("$summary", `Retrieved conversation successfully: ${this.conversationId}`);
return response;
},
};
Loading
Loading