diff --git a/components/dixa/actions/add-message/add-message.mjs b/components/dixa/actions/add-message/add-message.mjs new file mode 100644 index 0000000000000..8e9daaff33cd3 --- /dev/null +++ b/components/dixa/actions/add-message/add-message.mjs @@ -0,0 +1,67 @@ +import dixa from "../../dixa.app.mjs"; + +export default { + key: "dixa-add-message", + name: "Add Message to Conversation", + description: "Adds a message to an existing conversation. [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Conversations/#tag/Conversations/operation/postConversationsConversationidMessages).", + version: "0.0.1", + type: "action", + props: { + dixa, + endUserId: { + propDefinition: [ + dixa, + "endUserId", + ], + }, + conversationId: { + propDefinition: [ + dixa, + "conversationId", + ({ endUserId }) => ({ + endUserId, + }), + ], + }, + content: { + type: "string", + label: "Content", + description: "Content of the message", + }, + direction: { + propDefinition: [ + dixa, + "direction", + ], + reloadProps: true, + }, + agentId: { + propDefinition: [ + dixa, + "agentId", + ], + }, + }, + async additionalProps(props) { + props.agentId.hidden = this.direction !== "Outbound"; + return {}; + }, + async run({ $ }) { + const response = await this.dixa.addMessage({ + $, + conversationId: this.conversationId, + data: { + agentId: this.direction === "Outbound" + ? this.agentId + : undefined, + content: { + value: this.content, + _type: "Text", + }, + _type: this.direction, + }, + }); + $.export("$summary", `Added message to conversation ${this.conversationId}`); + return response; + }, +}; diff --git a/components/dixa/actions/create-conversation/create-conversation.mjs b/components/dixa/actions/create-conversation/create-conversation.mjs new file mode 100644 index 0000000000000..6afa9624db276 --- /dev/null +++ b/components/dixa/actions/create-conversation/create-conversation.mjs @@ -0,0 +1,102 @@ +import dixa from "../../dixa.app.mjs"; + +export default { + key: "dixa-create-conversation", + name: "Create Conversation", + description: "Creates a new email or contact form-based conversation. [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Conversations/#tag/Conversations/operation/postConversations).", + version: "0.0.1", + type: "action", + props: { + dixa, + requesterId: { + propDefinition: [ + dixa, + "endUserId", + ], + label: "Requester Id", + }, + direction: { + propDefinition: [ + dixa, + "direction", + ], + reloadProps: true, + }, + channel: { + type: "string", + label: "Channel", + description: "For outbound, only Email is supported. Inbound also supports ContactForm.", + options: [ + "Email", + "ContactForm", + ], + }, + emailIntegrationId: { + propDefinition: [ + dixa, + "emailIntegrationId", + ], + }, + subject: { + propDefinition: [ + dixa, + "subject", + ], + }, + message: { + type: "string", + label: "Message", + description: "The content message.", + }, + language: { + propDefinition: [ + dixa, + "language", + ], + optional: true, + }, + agentId: { + propDefinition: [ + dixa, + "agentId", + ], + optional: true, + }, + }, + async additionalProps(props) { + props.agentId.hidden = !(this.direction === "Outbound"); + props.channel.options = this.direction === "Outbound" + ? [ + "Email", + ] + : [ + "ContactForm", + "Email", + ]; + return {}; + }, + async run({ $ }) { + const response = await this.dixa.createConversation({ + $, + data: { + subject: this.subject, + emailIntegrationId: this.emailIntegrationId, + language: this.language, + requesterId: this.requesterId, + message: { + agentId: this.direction === "Outbound" + ? this.agentId + : undefined, + content: { + _type: "Text", + value: this.message, + }, + _type: this.direction, + }, + _type: this.channel, + }, + }); + $.export("$summary", `Created conversation with Id: ${response.data.id}`); + return response; + }, +}; diff --git a/components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs b/components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs new file mode 100644 index 0000000000000..d4c39c1657915 --- /dev/null +++ b/components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs @@ -0,0 +1,98 @@ +import dixa from "../../dixa.app.mjs"; + +export default { + key: "dixa-set-custom-contact-attributes", + name: "Set Custom Contact Attributes", + description: "Updates custom attributes for a specified user. [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Custom-Attributes/#tag/Custom-Attributes/operation/patchEndusersUseridCustom-attributes)", + version: "0.0.1", + type: "action", + props: { + dixa, + userId: { + propDefinition: [ + dixa, + "endUserId", + ], + reloadProps: true, + }, + }, + async additionalProps() { + const props = {}; + const { data } = await this.dixa.listCustomAttributes(); + + for (const item of data) { + if (item.isDeactivated || item.isArchived || item.entityType != "Contact") continue; + + props[item.id] = { + type: "string", + label: item.label, + description: item.description, + optional: !item.isRequired, + default: item.inputDefinition.placeholder, + }; + + if (item.inputDefinition._type === "Select") { + props[item.id].options = this.prepareOptions(item.inputDefinition.options); + } + } + return props; + }, + methods: { + prepareOptions(options, parentVal = "", parentLabel = "") { + const newOptions = []; + + for (const opt of options) { + const newLabel = parentLabel + ? `${parentLabel} - ${opt.label}` + : opt.label; + + const newVal = parentVal + ? `${parentVal}/${opt.value}` + : opt.value; + + if (opt.nestedOptions.length) { + newOptions.push(...this.prepareOptions(opt.nestedOptions, newVal, newLabel)); + } else { + newOptions.push({ + label: newLabel, + value: newVal, + }); + } + } + return newOptions; + }, + async prepareData(data) { + const response = {}; + const { data: customAttributes } = await this.dixa.listCustomAttributes(); + Object.entries(data).map(([ + key, + val, + ]) => { + const customAttribute = customAttributes.find((attr) => attr.id === key); + + response[key] = customAttribute.inputDefinition._type != "Text" + ? val.split("/") + : val; + }); + return response; + }, + }, + async run({ $ }) { + const { + dixa, + // eslint-disable-next-line no-unused-vars + prepareOptions, + prepareData, + userId, + ...data + } = this; + + const response = await dixa.updateCustomAttributes({ + $, + userId, + data: await prepareData(data), + }); + $.export("$summary", `Updated custom attributes for user ${this.userId}`); + return response; + }, +}; diff --git a/components/dixa/actions/tag-conversation/tag-conversation.mjs b/components/dixa/actions/tag-conversation/tag-conversation.mjs new file mode 100644 index 0000000000000..5427ff70441a3 --- /dev/null +++ b/components/dixa/actions/tag-conversation/tag-conversation.mjs @@ -0,0 +1,42 @@ +import dixa from "../../dixa.app.mjs"; + +export default { + key: "dixa-tag-conversation", + name: "Add Tag to Conversation", + description: "Adds a tag to a conversation. [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Tags/#tag/Tags/operation/putConversationsConversationidTagsTagid)", + version: "0.0.1", + type: "action", + props: { + dixa, + endUserId: { + propDefinition: [ + dixa, + "endUserId", + ], + }, + conversationId: { + propDefinition: [ + dixa, + "conversationId", + ({ endUserId }) => ({ + endUserId, + }), + ], + }, + tagId: { + propDefinition: [ + dixa, + "tagId", + ], + }, + }, + async run({ $ }) { + const response = await this.dixa.addTag({ + $, + conversationId: this.conversationId, + tagId: this.tagId, + }); + $.export("$summary", `Added tag ${this.tagId} to conversation ${this.conversationId}`); + return response; + }, +}; diff --git a/components/dixa/dixa.app.mjs b/components/dixa/dixa.app.mjs index b026f32de8633..d637977931ddf 100644 --- a/components/dixa/dixa.app.mjs +++ b/components/dixa/dixa.app.mjs @@ -1,11 +1,212 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "dixa", - propDefinitions: {}, + propDefinitions: { + endUserId: { + type: "string", + label: "End User Id", + description: "The id of the end user.", + async options({ page }) { + const { data } = await this.listEndUsers({ + params: { + page: page + 1, + }, + }); + return data.map(({ + id: value, displayName: label, + }) => ({ + label, + value, + })); + }, + }, + direction: { + type: "string", + label: "Direction", + description: "The direction of the message", + options: [ + "Inbound", + "Outbound", + ], + }, + emailIntegrationId: { + type: "string", + label: "Email Integration ID", + description: "The contact endpoint in the organization.", + async options() { + const { data } = await this.listContactEndpoints(); + return data.filter(({ _type }) => _type === "EmailEndpoint").map(({ address }) => address); + }, + }, + subject: { + type: "string", + label: "Subject", + description: "The subject of the conversation", + }, + language: { + type: "string", + label: "Language", + description: "The [2-letter ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) language of the conversation", + }, + agentId: { + type: "string", + label: "Agent Id", + description: "The id of the agent.", + hidden: true, + async options({ page }) { + const { data } = await this.listAgents({ + params: { + page: page + 1, + }, + }); + + return data.map(({ + id: value, displayName: label, + }) => ({ + label, + value, + })); + }, + }, + conversationId: { + type: "string", + label: "Conversation ID", + description: "The ID of the conversation", + async options({ endUserId }) { + const { data } = await this.listConversations({ + endUserId, + }); + return data.map(({ + id: value, direction, toEmail, fromEmail, + }) => { + return { + label: `${direction} - ${direction === "Inbound" + ? fromEmail + : toEmail}`, + value, + }; + }); + }, + }, + tagId: { + type: "string", + label: "Tag ID", + description: "The ID of the tag to add", + async options() { + const { data } = await this.listTags(); + return data + .filter(({ state }) => state === "Active") + .map(({ + id: value, name: label, + }) => ({ + label, + value, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://dev.dixa.io/v1"; + }, + _headers() { + return { + "authorization": `${this.$auth.api_key}`, + }; + }, + _makeRequest({ + $ = this, path, ...opts + }) { + return axios($, { + url: this._baseUrl() + path, + headers: this._headers(), + ...opts, + }); + }, + listEndUsers(opts = {}) { + return this._makeRequest({ + path: "/endusers", + ...opts, + }); + }, + listAgents(opts = {}) { + return this._makeRequest({ + path: "/agents", + ...opts, + }); + }, + listContactEndpoints(opts = {}) { + return this._makeRequest({ + path: "/contact-endpoints", + ...opts, + }); + }, + listConversations({ + endUserId, ...opts + }) { + return this._makeRequest({ + path: `/endusers/${endUserId}/conversations`, + ...opts, + }); + }, + listCustomAttributes() { + return this._makeRequest({ + path: "/custom-attributes", + }); + }, + addTag({ + conversationId, tagId, + }) { + return this._makeRequest({ + method: "PUT", + path: `/conversations/${conversationId}/tags/${tagId}`, + }); + }, + updateCustomAttributes({ + userId, ...opts + }) { + return this._makeRequest({ + method: "PATCH", + path: `/endusers/${userId}/custom-attributes`, + ...opts, + }); + }, + createWebhook(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/webhooks", + ...opts, + }); + }, + deleteWebhook(webhookId) { + return this._makeRequest({ + method: "DELETE", + path: `/webhooks/${webhookId}`, + }); + }, + listTags(opts = {}) { + return this._makeRequest({ + path: "/tags", + ...opts, + }); + }, + createConversation(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/conversations", + ...opts, + }); + }, + addMessage({ + conversationId, ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/conversations/${conversationId}/messages`, + ...opts, + }); }, }, }; diff --git a/components/dixa/package.json b/components/dixa/package.json index 3434eb1846aad..f7012f0fe3697 100644 --- a/components/dixa/package.json +++ b/components/dixa/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/dixa", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Dixa Components", "main": "dixa.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/components/dixa/sources/common/base.mjs b/components/dixa/sources/common/base.mjs new file mode 100644 index 0000000000000..bbe2c47f7c7f5 --- /dev/null +++ b/components/dixa/sources/common/base.mjs @@ -0,0 +1,49 @@ +import dixa from "../../dixa.app.mjs"; + +export default { + props: { + dixa, + http: "$.interface.http", + db: "$.service.db", + name: { + type: "string", + label: "Name", + description: "The Webhook Subscription name", + }, + }, + methods: { + _getHookId() { + return this.db.get("hookId"); + }, + _setHookId(hookId) { + this.db.set("hookId", hookId); + }, + }, + hooks: { + async activate() { + const response = await this.dixa.createWebhook({ + data: { + name: this.name, + url: this.http.endpoint, + events: this.getEventType(), + authorization: { + _type: "NoAuth", + }, + }, + }); + this._setHookId(response.data.id); + }, + async deactivate() { + const webhookId = this._getHookId(); + await this.dixa.deleteWebhook(webhookId); + }, + }, + async run({ body }) { + const ts = Date.now(); + this.$emit(body, { + id: body.event_id, + summary: this.getSummary(body), + ts: ts, + }); + }, +}; diff --git a/components/dixa/sources/conversation-status-changed-instant/conversation-status-changed-instant.mjs b/components/dixa/sources/conversation-status-changed-instant/conversation-status-changed-instant.mjs new file mode 100644 index 0000000000000..9d4fc452f49d6 --- /dev/null +++ b/components/dixa/sources/conversation-status-changed-instant/conversation-status-changed-instant.mjs @@ -0,0 +1,41 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "dixa-conversation-status-changed-instant", + name: "New Conversation Status Changed (Instant)", + description: "Emit new events when the status of a conversation changes (e.g., open, closed, or abandoned). [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Webhooks/).", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getEventType() { + return [ + "ConversationPending", + "ConversationMessageAdded", + "ConversationTagAdded", + "ConversationAssigned", + "ConversationPendingExpired", + "ConversationTransferred", + "ConversationEnqueued", + "ConversationCreated", + "ConversationUnassigned", + "ConversationOpen", + "ConversationAbandoned", + "ConversationClosed", + "ConversationNoteAdded", + "ConversationEndUserReplaced", + "ConversationTagRemoved", + "ConversationRated", + ]; + }, + getSummary({ + data, event_fqn: eventType, + }) { + return `Conversation ${data.conversation.csid} status changed to ${eventType}`; + }, + }, + sampleEmit, +}; diff --git a/components/dixa/sources/conversation-status-changed-instant/test-event.mjs b/components/dixa/sources/conversation-status-changed-instant/test-event.mjs new file mode 100644 index 0000000000000..f853fc35bbcd3 --- /dev/null +++ b/components/dixa/sources/conversation-status-changed-instant/test-event.mjs @@ -0,0 +1,42 @@ +export default { + "event_fqn": "CONVERSATION_PENDING", + "event_id": "12345678-1234-1234-1234-1234567890", + "event_timestamp": "2025-01-14T22:01:05.429Z", + "event_version": "1", + "organization": { + "id": "12345678-1234-1234-1234-1234567890", + "name": "Org Name" + }, + "data": { + "conversation": { + "assignee": { + "email": "email@dixa.com", + "id": "12345678-1234-1234-1234-1234567890", + "name": "Agent Name", + "phone": "+123456789", + "roles": [], + "user_type": "Member" + }, + "channel": "EMAIL", + "contact_point": "contact@email.dixa.io", + "created_at": "2025-01-13T19:48:33.178Z", + "csid": 2, + "direction": "OUTBOUND", + "queue": { + "id": "12345678-1234-1234-1234-1234567890", + "name": "default" + }, + "requester": { + "email": "contact@email.com", + "id": "12345678-1234-1234-1234-1234567890", + "name": "Contact Name", + "phone": null, + "roles": [], + "user_type": "Contact" + }, + "status": "PENDING", + "subject": "Subject Text", + "tags": [] + } + } +} \ No newline at end of file diff --git a/components/dixa/sources/new-conversation-created-instant/new-conversation-created-instant.mjs b/components/dixa/sources/new-conversation-created-instant/new-conversation-created-instant.mjs new file mode 100644 index 0000000000000..fa6e3bd3da5c2 --- /dev/null +++ b/components/dixa/sources/new-conversation-created-instant/new-conversation-created-instant.mjs @@ -0,0 +1,24 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "dixa-new-conversation-created-instant", + name: "New Conversation Created (Instant)", + description: "Emit new event when a conversation is created in Dixa. [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Webhooks/).", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getEventType() { + return [ + "ConversationCreated", + ]; + }, + getSummary({ data }) { + return `New conversation created with Id: ${data.conversation.csid}`; + }, + }, + sampleEmit, +}; diff --git a/components/dixa/sources/new-conversation-created-instant/test-event.mjs b/components/dixa/sources/new-conversation-created-instant/test-event.mjs new file mode 100644 index 0000000000000..c5a3311016db8 --- /dev/null +++ b/components/dixa/sources/new-conversation-created-instant/test-event.mjs @@ -0,0 +1,35 @@ +export default { + "event_fqn": "CONVERSATION_CREATED", + "event_id": "12345678-1234-1234-1234-1234567890", + "event_timestamp": "2025-01-14T22:01:05.429Z", + "event_version": "1", + "organization": { + "id": "12345678-1234-1234-1234-1234567890", + "name": "Org Name" + }, + "data": { + "conversation": { + "assignee": null, + "channel": "EMAIL", + "contact_point": "contact@email.dixa.io", + "created_at": "2025-01-13T19:48:33.178Z", + "csid": 2, + "direction": "INBOUND", + "queue": { + "id": "12345678-1234-1234-1234-1234567890", + "name": "default" + }, + "requester": { + "email": "contact@email.com", + "id": "12345678-1234-1234-1234-1234567890", + "name": "Contact Name", + "phone": null, + "roles": [], + "user_type": "Contact" + }, + "status": "OPEN", + "subject": "Subject Text", + "tags": [] + } + } +} \ No newline at end of file diff --git a/components/dixa/sources/new-customer-satisfaction-rating-instant/new-customer-satisfaction-rating-instant.mjs b/components/dixa/sources/new-customer-satisfaction-rating-instant/new-customer-satisfaction-rating-instant.mjs new file mode 100644 index 0000000000000..8cc259dbc8f03 --- /dev/null +++ b/components/dixa/sources/new-customer-satisfaction-rating-instant/new-customer-satisfaction-rating-instant.mjs @@ -0,0 +1,24 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "dixa-new-customer-satisfaction-rating-instant", + name: "New Customer Satisfaction Rating (Instant)", + description: "Emit new event when a customer submits a satisfaction rating for a conversation. [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Webhooks/).", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getEventType() { + return [ + "ConversationRated", + ]; + }, + getSummary({ data }) { + return `New satisfaction rating for conversation ${data.conversation.csid}`; + }, + }, + sampleEmit, +}; diff --git a/components/dixa/sources/new-customer-satisfaction-rating-instant/test-event.mjs b/components/dixa/sources/new-customer-satisfaction-rating-instant/test-event.mjs new file mode 100644 index 0000000000000..77287d17ba3c2 --- /dev/null +++ b/components/dixa/sources/new-customer-satisfaction-rating-instant/test-event.mjs @@ -0,0 +1,53 @@ +export default { + "event_fqn": "CONVERSATION_RATED", + "event_id": "12345678-1234-1234-1234-1234567890", + "event_timestamp": "2025-01-14T22:01:05.429Z", + "event_version": "1", + "organization": { + "id": "12345678-1234-1234-1234-1234567890", + "name": "Org Name" + }, + "data": { + "agent": { + "email": "email@dixa.com", + "id": "12345678-1234-1234-1234-1234567890", + "name": "Agent Name", + "phone": "+123456789", + "roles": [], + "user_type": "Member" + }, + "comment": "Best customer service ever!", + "conversation": { + "assignee": { + "email": "email@dixa.com", + "id": "12345678-1234-1234-1234-1234567890", + "name": "Agent Name", + "phone": "+123456789", + "roles": [], + "user_type": "Member" + }, + "channel": "EMAIL", + "contact_point": "contact@email.dixa.io", + "created_at": "2025-01-13T19:48:33.178Z", + "csid": 2, + "direction": "OUTBOUND", + "queue": { + "id": "12345678-1234-1234-1234-1234567890", + "name": "default" + }, + "requester": { + "email": "contact@email.com", + "id": "12345678-1234-1234-1234-1234567890", + "name": "Contact Name", + "phone": null, + "roles": [], + "user_type": "Contact" + }, + "status": "CLOSED", + "subject": "Subject Text", + "tags": [], + "score": 4, + "type": "Csat" + } + } +} \ No newline at end of file diff --git a/components/dixa/sources/new-message-added-instant/new-message-added-instant.mjs b/components/dixa/sources/new-message-added-instant/new-message-added-instant.mjs new file mode 100644 index 0000000000000..f499673b4ab3e --- /dev/null +++ b/components/dixa/sources/new-message-added-instant/new-message-added-instant.mjs @@ -0,0 +1,24 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "dixa-new-message-added-instant", + name: "New Message Added to Conversation (Instant)", + description: "Emit new event when a new message is added to a conversation. [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Webhooks/).", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getEventType() { + return [ + "ConversationMessageAdded", + ]; + }, + getSummary({ data }) { + return `New message in conversation ${data.conversation.csid}`; + }, + }, + sampleEmit, +}; diff --git a/components/dixa/sources/new-message-added-instant/test-event.mjs b/components/dixa/sources/new-message-added-instant/test-event.mjs new file mode 100644 index 0000000000000..18d41dbe56419 --- /dev/null +++ b/components/dixa/sources/new-message-added-instant/test-event.mjs @@ -0,0 +1,62 @@ +export default { + "event_fqn": "CONVERSATION_MESSAGE_ADDED", + "event_id": "12345678-1234-1234-1234-1234567890", + "event_timestamp": "2025-01-14T22:01:05.429Z", + "event_version": "1", + "organization": { + "id": "12345678-1234-1234-1234-1234567890", + "name": "Org Name" + }, + "data": { + "author": { + "email": "email@dixa.com", + "id": "12345678-1234-1234-1234-1234567890", + "name": "Agent Name", + "phone": "+123456789", + "roles": [], + "user_type": "Member" + }, + "channel": "EMAIL", + "content": { + "text":"Message Text", + "content_type":"Text", + "original_content_url":null, + "processed_content_url":null + }, + "conversation": { + "assignee": { + "email": "email@dixa.com", + "id": "12345678-1234-1234-1234-1234567890", + "name": "Agent Name", + "phone": "+123456789", + "roles": [], + "user_type": "Member" + }, + "channel": "EMAIL", + "contact_point": "contact@email.dixa.io", + "created_at": "2025-01-13T19:48:33.178Z", + "csid": 2, + "direction": "OUTBOUND", + "queue": { + "id": "12345678-1234-1234-1234-1234567890", + "name": "default" + }, + "requester": { + "email": "contact@email.com", + "id": "12345678-1234-1234-1234-1234567890", + "name": "Contact Name", + "phone": null, + "roles": [], + "user_type": "Contact" + }, + "status": "PENDING", + "subject": "Subject Text", + "tags": [] + }, + "created_at":"2025-01-14T23:08:43.187Z", + "direction":"outbound", + "external_id":"null", + "message_id":"12345678-1234-1234-1234-1234567890", + "text":"Message Text", + } +} \ No newline at end of file diff --git a/components/dixa/sources/new-tag-added-instant/new-tag-added-instant.mjs b/components/dixa/sources/new-tag-added-instant/new-tag-added-instant.mjs new file mode 100644 index 0000000000000..4b2c6109c4ef9 --- /dev/null +++ b/components/dixa/sources/new-tag-added-instant/new-tag-added-instant.mjs @@ -0,0 +1,24 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "dixa-new-tag-added-instant", + name: "New Tag Added in Conversation (Instant)", + description: "Emit new event when a tag is added to a conversation. [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Webhooks/).", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getEventType() { + return [ + "ConversationTagAdded", + ]; + }, + getSummary({ data }) { + return `Tag "${data.tag}" added to conversation ${data.conversation.csid}`; + }, + }, + sampleEmit, +}; diff --git a/components/dixa/sources/new-tag-added-instant/test-event.mjs b/components/dixa/sources/new-tag-added-instant/test-event.mjs new file mode 100644 index 0000000000000..1bc7dac26796f --- /dev/null +++ b/components/dixa/sources/new-tag-added-instant/test-event.mjs @@ -0,0 +1,57 @@ +export default { + "event_fqn": "CONVERSATION_TAG_ADDED", + "event_id": "12345678-1234-1234-1234-1234567890", + "event_timestamp": "2025-01-14T22:01:05.429Z", + "event_version": "1", + "organization": { + "id": "12345678-1234-1234-1234-1234567890", + "name": "Org Name" + }, + "data": { + "author": { + "email": "email@dixa.com", + "id": "12345678-1234-1234-1234-1234567890", + "name": "Agent Name", + "phone": "+123456789", + "roles": [], + "user_type": "Member" + }, + "tag": "Tag Name", + "conversation": { + "assignee": { + "email": "email@dixa.com", + "id": "12345678-1234-1234-1234-1234567890", + "name": "Agent Name", + "phone": "+123456789", + "roles": [], + "user_type": "Member" + }, + "channel": "EMAIL", + "contact_point": "contact@email.dixa.io", + "created_at": "2025-01-13T19:48:33.178Z", + "csid": 2, + "direction": "OUTBOUND", + "queue": { + "id": "12345678-1234-1234-1234-1234567890", + "name": "default" + }, + "requester": { + "email": "contact@email.com", + "id": "12345678-1234-1234-1234-1234567890", + "name": "Contact Name", + "phone": null, + "roles": [], + "user_type": "Contact" + }, + "status": "PENDING", + "subject": "Subject Text", + "tags": [ + { + "id":"12345678-1234-1234-1234-1234567890", + "name":"Tag Name", + "is_deactivated":false + } + ] + } + } +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5be7b5b9df1bd..050f62febfee8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2796,7 +2796,11 @@ importers: components/dispatch: {} - components/dixa: {} + components/dixa: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/dnsfilter: dependencies: