Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
60 changes: 60 additions & 0 deletions components/belco/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Belco Component

This component provides integration with the Belco API for managing conversations and customer support.

## Sources

### New Conversation
- **Key**: `belco-new-conversation`
- **Description**: Emits a new conversation event when a new conversation is created.
- **Documentation**: [Get Conversations API](https://developers.belco.io/reference/get_conversations)

## Actions

### List All Conversations
- **Key**: `belco-list-all-conversations`
- **Description**: Get a list of conversations
- **Documentation**: [Get Conversations API](https://developers.belco.io/reference/get_conversations)

### Create Conversation
- **Key**: `belco-create-conversation`
- **Description**: Create a conversation. Required props: shopId, channel and body. Optional props: type, from, to and subject.
- **Documentation**: [Post Conversations API](https://developers.belco.io/reference/post_conversations)

### Send Message
- **Key**: `belco-send-message`
- **Description**: Send a message to a conversation. Required props: shopId, channel and body. Optional props: type, from, to and subject.
- **Documentation**: [Post Conversations Send Message API](https://developers.belco.io/reference/post_conversations-sendmessage)

### Retrieve Conversation
- **Key**: `belco-retrieve-conversation`
- **Description**: Retrieve a conversation. Required props: conversationId. Optional props: fromDate, toDate, and sortOrder.
- **Documentation**: [Get Conversations Conversation ID API](https://developers.belco.io/reference/get_conversations-conversationid)

### Close Conversation
- **Key**: `belco-close-conversation`
- **Description**: Close a conversation. Required props: conversationId.
- **Documentation**: [Put Conversations Conversation ID Close API](https://developers.belco.io/reference/put_conversations-conversationid-close)

### Reopen Conversation
- **Key**: `belco-reopen-conversation`
- **Description**: Reopen a conversation. Required props: conversationId.
- **Documentation**: [Put Conversations Conversation ID Open API](https://developers.belco.io/reference/put_conversations-conversationid-open)

### Reply to Conversation
- **Key**: `belco-reply-to-conversation`
- **Description**: Reply to a conversation. Required props: conversationId and body.
- **Documentation**: [Put Conversations Conversation ID Reply API](https://developers.belco.io/reference/put_conversations-conversationid-reply)

### Add Note to Conversation
- **Key**: `belco-add-note-to-conversation`
- **Description**: Add a note to a conversation. Required props: conversationId and body.
- **Documentation**: [Put Conversations Conversation ID Add Note API](https://developers.belco.io/reference/put_conversations-conversationid-addnote)

## Authentication

This component uses API key authentication. You'll need to provide your Belco API key in the component configuration.

## API Documentation

For more information about the Belco API, visit: https://developers.belco.io/reference
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