diff --git a/components/help_scout/actions/add-note/add-note.mjs b/components/help_scout/actions/add-note/add-note.mjs new file mode 100644 index 0000000000000..ebb02f2770e0b --- /dev/null +++ b/components/help_scout/actions/add-note/add-note.mjs @@ -0,0 +1,43 @@ +import helpScout from "../../help_scout.app.mjs"; + +export default { + key: "help_scout-add-note", + name: "Add Note to Conversation", + description: "Adds a note to an existing conversation in Help Scout. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/note/)", + version: "0.0.1", + type: "action", + props: { + helpScout, + conversationId: { + propDefinition: [ + helpScout, + "conversationId", + ], + }, + text: { + propDefinition: [ + helpScout, + "text", + ], + }, + userId: { + propDefinition: [ + helpScout, + "userId", + ], + optional: true, + }, + }, + async run({ $ }) { + const response = await this.helpScout.addNoteToConversation({ + $, + conversationId: this.conversationId, + data: { + text: this.text, + user: this.userId, + }, + }); + $.export("$summary", `Successfully added note to conversation ID: ${this.conversationId}`); + return response; + }, +}; diff --git a/components/help_scout/actions/create-customer/create-customer.mjs b/components/help_scout/actions/create-customer/create-customer.mjs new file mode 100644 index 0000000000000..cec309bb7c831 --- /dev/null +++ b/components/help_scout/actions/create-customer/create-customer.mjs @@ -0,0 +1,205 @@ +import { ConfigurationError } from "@pipedream/platform"; +import { + GENDER_OPTIONS, + PHOTO_TYPE_OPTIONS, +} from "../../common/constants.mjs"; +import { + cleanObject, + parseObject, +} from "../../common/utils.mjs"; +import helpScout from "../../help_scout.app.mjs"; + +export default { + key: "help_scout-create-customer", + name: "Create Customer", + description: "Creates a new customer record in Help Scout. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/customers/create/)", + version: "0.0.1", + type: "action", + props: { + helpScout, + firstName: { + type: "string", + label: "First Name", + description: "First name of the customer. When defined it must be between 1 and 40 characters.", + optional: true, + }, + lastName: { + type: "string", + label: "Last Name", + description: "Last name of the customer. When defined it must be between 1 and 40 characters.", + optional: true, + }, + phone: { + type: "string", + label: "Phone", + description: "The phone number that will be used when creating a new customer.", + optional: true, + }, + photoUrl: { + type: "string", + label: "Photo URL", + description: "URL of the customer's photo. Max length 200 characters.", + optional: true, + }, + jobTitle: { + type: "string", + label: "Job Title", + description: "Job title. Max length 60 characters.", + optional: true, + }, + photoType: { + type: "string", + label: "Photo Type", + description: "The type of photo.", + options: PHOTO_TYPE_OPTIONS, + optional: true, + }, + background: { + type: "string", + label: "Background", + description: "This is the Notes field from the user interface. Max length 200 characters.", + optional: true, + }, + location: { + type: "string", + label: "Location", + description: "Location of the customer. Max length 60 characters.", + optional: true, + }, + organization: { + type: "string", + label: "Organization", + description: "Organization. Max length 60 characters.", + optional: true, + }, + gender: { + type: "string", + label: "Gender", + description: "Gender of this customer.", + options: GENDER_OPTIONS, + optional: true, + }, + age: { + type: "string", + label: "Age", + description: "Customer's age.", + optional: true, + }, + emails: { + type: "string[]", + label: "Emails", + description: "List of email entries. **Format: {\"type\":\"home\",\"value\":\"customer@email.com\"}**. see [Create Email](https://developer.helpscout.com/mailbox-api/endpoints/customers/emails/create) for the object documentation.", + optional: true, + }, + phones: { + type: "string[]", + label: "Phones", + description: "List of phone entries. **Format: {\"type\":\"work\",\"value\":\"222-333-4444\"}**. see [Create Phone](https://developer.helpscout.com/mailbox-api/endpoints/customers/phones/create) for the object documentation.", + optional: true, + }, + chats: { + type: "string[]", + label: "Chats", + description: "List of chat entries. **Format: {\"type\":\"aim\",\"value\":\"jsprout\"}**. see [Create Chat Handle](https://developer.helpscout.com/mailbox-api/endpoints/customers/chat_handles/create) for the object documentation.", + optional: true, + }, + socialProfiles: { + type: "string[]", + label: "Social Profiles", + description: "List of social profile entries. **Format: {\"type\":\"googleplus\",\"value\":\"https://api.helpscout.net/+HelpscoutNet\"}**. see [Create Social Profile](https://developer.helpscout.com/mailbox-api/endpoints/customers/social_profiles/create) for the object documentation.", + optional: true, + }, + websites: { + type: "string[]", + label: "Websites", + description: "List of websites entries. **Format: {\"value\":\"https://api.helpscout.net/\"}**. see [Create Website](https://developer.helpscout.com/mailbox-api/endpoints/customers/websites/create) for the object documentation.", + optional: true, + }, + addressCity: { + type: "string", + label: "Address City", + description: "The city of the customer.", + optional: true, + }, + addressState: { + type: "string", + label: "Address State", + description: "The state of the customer.", + optional: true, + }, + addressPostalCode: { + type: "string", + label: "Address Postal Code", + description: "The postal code of the customer.", + optional: true, + }, + addressCountry: { + type: "string", + label: "Address Country", + description: "The [ISO 3166 Alpha-2 code](https://www.iban.com/country-codes) country of the customer.", + optional: true, + }, + addressLines: { + type: "string[]", + label: "Address Lines", + description: "A list of address lines.", + optional: true, + }, + properties: { + type: "string[]", + label: "Properties", + description: "List of social profile entries. **Format: {\"type\":\"googleplus\",\"value\":\"https://api.helpscout.net/+HelpscoutNet\"}**. see [Create Social Profile](https://developer.helpscout.com/mailbox-api/endpoints/customers/social_profiles/create) for the object documentation.", + optional: true, + }, + }, + async run({ $ }) { + const address = cleanObject({ + city: this.addressCity, + state: this.addressState, + postalCode: this.addressPostalCode, + country: this.addressCountry, + lines: parseObject(this.addressLines), + properties: parseObject(this.properties), + }); + + let data = {}; + + data = cleanObject({ + firstName: this.firstName, + lastName: this.lastName, + phone: this.phone, + photoUrl: this.photoUrl, + jobTitle: this.jobTitle, + photoType: this.photoType, + background: this.background, + location: this.location, + organization: this.organization, + gender: this.gender, + age: this.age, + emails: parseObject(this.emails), + phones: parseObject(this.phones), + chats: parseObject(this.chats), + socialProfiles: parseObject(this.socialProfiles), + websites: parseObject(this.websites), + }); + + if (Object.keys(address).length) data.address = address; + + if (!Object.keys(data).length) { + throw new ConfigurationError("At least one field or customer entry must be defined."); + } + + try { + const response = await this.helpScout.createCustomer({ + $, + data, + }); + + $.export("$summary", "Successfully created the new customer."); + return response; + } catch ({ message }) { + const error = JSON.parse(message)._embedded.errors[0]; + throw new ConfigurationError(`Path: ${error.path} - ${error.message}`); + } + }, +}; diff --git a/components/help_scout/actions/send-reply/send-reply.mjs b/components/help_scout/actions/send-reply/send-reply.mjs new file mode 100644 index 0000000000000..61673ae81a8b5 --- /dev/null +++ b/components/help_scout/actions/send-reply/send-reply.mjs @@ -0,0 +1,53 @@ +import helpScout from "../../help_scout.app.mjs"; + +export default { + key: "help_scout-send-reply", + name: "Send Reply", + description: "Sends a reply to a conversation. Be careful as this sends an actual email to the customer. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/reply/)", + version: "0.0.1", + type: "action", + props: { + helpScout, + conversationId: { + propDefinition: [ + helpScout, + "conversationId", + ], + }, + customerId: { + propDefinition: [ + helpScout, + "customerId", + ], + }, + text: { + propDefinition: [ + helpScout, + "text", + ], + description: "The content of the reply.", + }, + draft: { + type: "boolean", + label: "Draft", + description: "If set to true, a draft reply is created.", + default: false, + }, + }, + async run({ $ }) { + const response = await this.helpScout.sendReplyToConversation({ + $, + conversationId: this.conversationId, + data: { + customer: { + id: this.customerId, + }, + text: this.text, + draft: this.draft, + }, + }); + + $.export("$summary", `Reply sent successfully to conversation ID: ${this.conversationId}`); + return response; + }, +}; diff --git a/components/help_scout/common/constants.mjs b/components/help_scout/common/constants.mjs new file mode 100644 index 0000000000000..76d42ac05aaa4 --- /dev/null +++ b/components/help_scout/common/constants.mjs @@ -0,0 +1,16 @@ +export const PHOTO_TYPE_OPTIONS = [ + "unknown", + "gravatar", + "twitter", + "facebook", + "googleprofile", + "googleplus", + "linkedin", + "instagram", +]; + +export const GENDER_OPTIONS = [ + "male", + "female", + "unknown", +]; diff --git a/components/help_scout/common/utils.mjs b/components/help_scout/common/utils.mjs new file mode 100644 index 0000000000000..8fabcd59a844c --- /dev/null +++ b/components/help_scout/common/utils.mjs @@ -0,0 +1,33 @@ +export const parseObject = (obj) => { + if (!obj) return undefined; + + if (Array.isArray(obj)) { + return obj.map((item) => { + if (typeof item === "string") { + try { + return JSON.parse(item); + } catch (e) { + return item; + } + } + return item; + }); + } + if (typeof obj === "string") { + try { + return JSON.parse(obj); + } catch (e) { + return obj; + } + } + return obj; +}; + +export const cleanObject = (o) => { + for (var k in o || {}) { + if (typeof o[k] === "undefined") { + delete o[k]; + } + } + return o; +}; diff --git a/components/help_scout/help_scout.app.mjs b/components/help_scout/help_scout.app.mjs index 7f6e469dcb48f..4b8b4ad42e146 100644 --- a/components/help_scout/help_scout.app.mjs +++ b/components/help_scout/help_scout.app.mjs @@ -1,11 +1,150 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "help_scout", - propDefinitions: {}, + propDefinitions: { + agentId: { + type: "string", + label: "Agent ID", + description: "ID of the agent to whom the conversation is assigned.", + }, + conversationId: { + type: "string", + label: "Conversation ID", + description: "The unique identifier of the conversation.", + async options({ page }) { + const { _embedded: { conversations } } = await this.listConversations({ + params: { + page: page + 1, + }, + }); + + return conversations.map(({ + id: value, subject, primaryCustomer: { email }, + }) => ({ + label: `${subject}(${value}) - ${email}`, + value, + })); + }, + }, + customerId: { + type: "string", + label: "Customer ID", + description: "The unique identifier of the customer.", + async options({ page }) { + const { _embedded: { customers } } = await this.listCustomers({ + params: { + page: page + 1, + }, + }); + + return customers.map(({ + id: value, firstName, lastName, _embedded: { emails }, + }) => ({ + label: `${firstName} ${lastName} - ${emails[0].id}`, + value, + })); + }, + }, + userId: { + type: "string", + label: "User ID", + description: "The unique identifier of the user.", + async options({ page }) { + const { _embedded: { users } } = await this.listUsers({ + params: { + page: page + 1, + }, + }); + + return users.map(({ + id: value, email: label, + }) => ({ + label, + value, + })); + }, + }, + text: { + type: "string", + label: "Text", + description: "The content of the note.", + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.helpscout.net/v2"; + }, + _headers() { + return { + Authorization: `Bearer ${this.$auth.oauth_access_token}`, + }; + }, + _makeRequest({ + $ = this, path, ...opts + }) { + return axios($, { + url: this._baseUrl() + path, + headers: this._headers(), + ...opts, + }); + }, + listConversations(opts = {}) { + return this._makeRequest({ + path: "/conversations", + ...opts, + }); + }, + listCustomers(opts = {}) { + return this._makeRequest({ + path: "/customers", + ...opts, + }); + }, + listUsers(opts = {}) { + return this._makeRequest({ + path: "/users", + ...opts, + }); + }, + createWebhook(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/webhooks", + ...opts, + }); + }, + deleteWebhook(webhookId) { + return this._makeRequest({ + method: "DELETE", + path: `/webhooks/${webhookId}`, + }); + }, + addNoteToConversation({ + conversationId, ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/conversations/${conversationId}/notes`, + ...opts, + }); + }, + createCustomer(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/customers", + ...opts, + }); + }, + sendReplyToConversation({ + conversationId, ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/conversations/${conversationId}/reply`, + ...opts, + }); }, }, }; diff --git a/components/help_scout/package.json b/components/help_scout/package.json new file mode 100644 index 0000000000000..2cbc959a07578 --- /dev/null +++ b/components/help_scout/package.json @@ -0,0 +1,20 @@ +{ + "name": "@pipedream/help_scout", + "version": "0.1.0", + "description": "Pipedream Help Scout Components", + "main": "help_scout.app.mjs", + "keywords": [ + "pipedream", + "help_scout" + ], + "homepage": "https://pipedream.com/apps/help_scout", + "author": "Pipedream (https://pipedream.com/)", + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3", + "crypto": "^1.0.1" + } +} + diff --git a/components/help_scout/sources/common/base.mjs b/components/help_scout/sources/common/base.mjs new file mode 100644 index 0000000000000..90329148e98d3 --- /dev/null +++ b/components/help_scout/sources/common/base.mjs @@ -0,0 +1,84 @@ +import crypto from "crypto"; +import helpScout from "../../help_scout.app.mjs"; + +export default { + props: { + helpScout, + http: { + type: "$.interface.http", + customResponse: true, + }, + db: "$.service.db", + label: { + type: "string", + label: "Label", + description: "Label associated with this WebHook for better clarity.", + optional: true, + }, + }, + methods: { + _getHookId() { + return this.db.get("hookId"); + }, + _setHookId(hookId) { + this.db.set("hookId", hookId); + }, + _getSecret() { + return this.db.get("secret"); + }, + _setSecret(secret) { + this.db.set("secret", secret); + }, + getExtraData() { + return {}; + }, + }, + hooks: { + async activate() { + const secret = crypto.randomBytes(64).toString("hex"); + const { headers } = await this.helpScout.createWebhook({ + returnFullResponse: true, + data: { + url: this.http.endpoint, + events: this.getEventType(), + label: this.label, + secret, + }, + }); + this._setSecret(secret); + this._setHookId(headers["resource-id"]); + }, + async deactivate() { + const webhookId = this._getHookId(); + await this.helpScout.deleteWebhook(webhookId); + }, + }, + async run({ + bodyRaw, body, headers, + }) { + const hsSignature = headers["x-helpscout-signature"]; + if (hsSignature) { + const secret = this._getSecret(); + const hash = crypto.createHmac("sha1", secret) + .update(bodyRaw) + .digest("base64"); + + if (hash != hsSignature) { + return this.http.respond({ + status: 400, + }); + } + } + + const ts = Date.parse(new Date()); + this.$emit(body, { + id: body.id, + summary: this.getSummary(body), + ts: ts, + }); + + return this.http.respond({ + status: 200, + }); + }, +}; diff --git a/components/help_scout/sources/new-conversation-assigned-instant/new-conversation-assigned-instant.mjs b/components/help_scout/sources/new-conversation-assigned-instant/new-conversation-assigned-instant.mjs new file mode 100644 index 0000000000000..947d6252fa4e8 --- /dev/null +++ b/components/help_scout/sources/new-conversation-assigned-instant/new-conversation-assigned-instant.mjs @@ -0,0 +1,24 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "help_scout-new-conversation-assigned-instant", + name: "New Conversation Assigned (Instant)", + description: "Emit new event when a conversation is assigned to an agent. [See the documentation](https://developer.helpscout.com/)", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getEventType() { + return [ + "convo.assigned", + ]; + }, + getSummary(body) { + return `New conversation assigned to ${body.assignee.email}`; + }, + }, + sampleEmit, +}; diff --git a/components/help_scout/sources/new-conversation-assigned-instant/test-event.mjs b/components/help_scout/sources/new-conversation-assigned-instant/test-event.mjs new file mode 100644 index 0000000000000..1935a35e8e9e9 --- /dev/null +++ b/components/help_scout/sources/new-conversation-assigned-instant/test-event.mjs @@ -0,0 +1,137 @@ +export default { + "id": 291938, + "type": "email", + "folderId": "1234", + "isDraft": "false", + "number": 349, + "owner": { + "id": 1234, + "firstName": "Jack", + "lastName": "Sprout", + "email": "jack.sprout@gmail.com", + "phone": null, + "type": "user" + }, + "mailbox": { + "id": 1234, + "name": "My Mailbox" + }, + "customer": { + "id": 29418, + "firstName": "Vernon", + "lastName": "Bear", + "email": "vbear@mywork.com", + "phone": "800-555-1212", + "type": "customer" + }, + "threadCount": 4, + "status": "active", + "subject": "I need help!", + "preview": "Hello, I tried to download the file off your site...", + "createdBy": { + "id": 29418, + "firstName": "Vernon", + "lastName": "Bear", + "email": "vbear@mywork.com", + "phone": null, + "type": "customer" + }, + "createdAt": "2012-07-23T12:34:12Z", + "modifiedAt": "2012-07-24T20:18:33Z", + "closedAt": null, + "closedBy": null, + "source": { + "type": "email", + "via": "customer" + }, + "cc": [ + "cc1@somewhere.com", + "cc2@somewhere.com" + ], + "bcc": [ + "bcc1@somewhere.com", + "bcc2@somewhere.com" + ], + "tags": [ + "tag1", + "tag2" + ], + "customFields": [ + { + "fieldId": 1, + "name": "Team", + "value": "Development" + }, + { + "fieldId": 2, + "name": "Customer Disposition", + "value": "Happy" + } + ], + "threads": [ + { + "id": 88171881, + "assignedTo": { + "id": 1234, + "firstName": "Jack", + "lastName": "Sprout", + "email": "jack.sprout@gmail.com", + "phone": null, + "type": "user" + }, + "status": "active", + "createdAt": "2012-07-23T12:34:12Z", + "createdBy": { + "id": 1234, + "firstName": "Jack", + "lastName": "Sprout", + "email": "jack.sprout@gmail.com", + "phone": null, + "type": "user" + }, + "source": { + "type": "web", + "via": "user" + }, + "type": "message", + "state": "published", + "customer": { + "id": 29418, + "firstName": "Vernon", + "lastName": "Bear", + "email": "vbear@mywork.com", + "phone": "800-555-1212", + "type": "customer" + }, + "fromMailbox": null, + "body": "This is what I have to say. Thank you.", + "to": [ + "customer@somewhere.com" + ], + "cc": [ + "cc1@somewhere.com", + "cc2@somewhere.com" + ], + "bcc": [ + "bcc1@somewhere.com", + "bcc2@somewhere.com" + ], + "attachments": [ + { + "id": 12391, + "mimeType": "image/jpeg", + "filename": "logo.jpg", + "size": 22, + "width": 160, + "height": 160, + "url": "https://secure.helpscout.net/some-url/logo.jpg" + } + ], + "tags": [ + "tag1", + "tag2", + "tag3" + ] + } + ] +} \ No newline at end of file diff --git a/components/help_scout/sources/new-conversation-created-instant/new-conversation-created-instant.mjs b/components/help_scout/sources/new-conversation-created-instant/new-conversation-created-instant.mjs new file mode 100644 index 0000000000000..37f0b97e12d52 --- /dev/null +++ b/components/help_scout/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: "help_scout-new-conversation-created-instant", + name: "New Conversation Created (Instant)", + description: "Emit new event when a new conversation is created.", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getEventType() { + return [ + "convo.created", + ]; + }, + getSummary(body) { + return `New conversation created: ${body.subject}`; + }, + }, + sampleEmit, +}; diff --git a/components/help_scout/sources/new-conversation-created-instant/test-event.mjs b/components/help_scout/sources/new-conversation-created-instant/test-event.mjs new file mode 100644 index 0000000000000..d8cc91fd9e8de --- /dev/null +++ b/components/help_scout/sources/new-conversation-created-instant/test-event.mjs @@ -0,0 +1,137 @@ +export default { + "id": 291938, + "type": "email", + "folderId": "1234", + "isDraft": "false", + "number": 349, + "owner": { + "id": 1234, + "firstName": "Jack", + "lastName": "Sprout", + "email": "jack.sprout@gmail.com", + "phone": null, + "type": "user" + }, + "mailbox": { + "id": 1234, + "name": "My Mailbox" + }, + "customer": { + "id": 29418, + "firstName": "Vernon", + "lastName": "Bear", + "email": "vbear@mywork.com", + "phone": "800-555-1212", + "type": "customer" + }, + "threadCount": 4, + "status": "active", + "subject": "I need help!", + "preview": "Hello, I tried to download the file off your site...", + "createdBy": { + "id": 29418, + "firstName": "Vernon", + "lastName": "Bear", + "email": "vbear@mywork.com", + "phone": null, + "type": "customer" + }, + "createdAt": "2012-07-23T12:34:12Z", + "modifiedAt": "2012-07-24T20:18:33Z", + "closedAt": null, + "closedBy": null, + "source": { + "type": "email", + "via": "customer" + }, + "cc": [ + "cc1@somewhere.com", + "cc2@somewhere.com" + ], + "bcc": [ + "bcc1@somewhere.com", + "bcc2@somewhere.com" + ], + "tags": [ + "tag1", + "tag2" + ], + "customFields": [ + { + "fieldId": 1, + "name": "Team", + "value": "Development" + }, + { + "fieldId": 2, + "name": "Customer Disposition", + "value": "Happy" + } + ], + "threads": [ + { + "id": 88171881, + "assignedTo": { + "id": 1234, + "firstName": "Jack", + "lastName": "Sprout", + "email": "jack.sprout@gmail.com", + "phone": null, + "type": "user" + }, + "status": "active", + "createdAt": "2012-07-23T12:34:12Z", + "createdBy": { + "id": 1234, + "firstName": "Jack", + "lastName": "Sprout", + "email": "jack.sprout@gmail.com", + "phone": null, + "type": "user" + }, + "source": { + "type": "web", + "via": "user" + }, + "type": "message", + "state": "published", + "customer": { + "id": 29418, + "firstName": "Vernon", + "lastName": "Bear", + "email": "vbear@mywork.com", + "phone": "800-555-1212", + "type": "customer" + }, + "fromMailbox": null, + "body": "This is what I have to say. Thank you.", + "to": [ + "customer@somewhere.com" + ], + "cc": [ + "cc1@somewhere.com", + "cc2@somewhere.com" + ], + "bcc": [ + "bcc1@somewhere.com", + "bcc2@somewhere.com" + ], + "attachments": [ + { + "id": 12391, + "mimeType": "image/jpeg", + "filename": "logo.jpg", + "size": 22, + "width": 160, + "height": 160, + "url": "https://secure.helpscout.net/some-url/logo.jpg" + } + ], + "tags": [ + "tag1", + "tag2", + "tag3" + ] + } + ] + } \ No newline at end of file diff --git a/components/help_scout/sources/new-customer-instant/new-customer-instant.mjs b/components/help_scout/sources/new-customer-instant/new-customer-instant.mjs new file mode 100644 index 0000000000000..766f7a78b6863 --- /dev/null +++ b/components/help_scout/sources/new-customer-instant/new-customer-instant.mjs @@ -0,0 +1,24 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "help_scout-new-customer-instant", + name: "New Customer Added (Instant)", + description: "Emit new event when a new customer is added.", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getEventType() { + return [ + "customer.created", + ]; + }, + getSummary(body) { + return `New customer created: ${body.firstName} ${body.lastName} - ${body._embedded.emails[0].value}`; + }, + }, + sampleEmit, +}; diff --git a/components/help_scout/sources/new-customer-instant/test-event.mjs b/components/help_scout/sources/new-customer-instant/test-event.mjs new file mode 100644 index 0000000000000..7070a334032db --- /dev/null +++ b/components/help_scout/sources/new-customer-instant/test-event.mjs @@ -0,0 +1,58 @@ +export default { + "id": 29418, + "firstName": "Vernon", + "lastName": "Bear", + "photoUrl": "http://twitter.com/img/some-avatar.jpg", + "photoType": "twitter", + "gender": "Male", + "age": "30-35", + "organization": "Acme, Inc", + "jobTitle": "CEO and Co-Founder", + "location": "Greater Dallas/FT Worth Area", + "background": "I've worked with Vernon before and he's really great.", + "createdAt": "2012-07-23T12:34:12Z", + "modifiedAt": "2012-07-24T20:18:33Z", + "address": { + "id": 1234, + "lines": [ + "123 West Main St", + "Suite 123" + ], + "city": "Dallas", + "state": "TX", + "postcalCode": "74206", + "country": "US", + "createdAt": "2012-07-23T12:34:12Z", + "modifiedAt": "2012-07-24T20:18:33Z" + }, + "socialProfiles": [ + { + "id": 9184, + "value": "https://twitter.com/helpscout", + "type": "twitter" + }, + ], + "emails": [{ + "id": 98131, + "value": "vbear@mywork.com", + "location": "work" + }, + ], + "phones": [{ + "id": 22381, + "value": "222-333-4444", + "location": "home" + }, + ], + "chats": [{ + "id": 77183, + "value": "jsprout", + "type": "aim" + }, + ], + "websites": [{ + "id": 5584, + "value": "http://www.somewhere.com" + }, + ] +} \ No newline at end of file diff --git a/components/help_scout/yarn.lock b/components/help_scout/yarn.lock new file mode 100644 index 0000000000000..144b3d8041ea3 --- /dev/null +++ b/components/help_scout/yarn.lock @@ -0,0 +1,8 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +crypto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/crypto/-/crypto-1.0.1.tgz#2af1b7cad8175d24c8a1b0778255794a21803037" + integrity sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig== diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 386208bb30d06..b4d4e286a77f0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4595,6 +4595,14 @@ importers: dependencies: '@pipedream/platform': 1.5.1 + components/help_scout: + specifiers: + '@pipedream/platform': ^3.0.3 + crypto: ^1.0.1 + dependencies: + '@pipedream/platform': 3.0.3 + crypto: 1.0.1 + components/helpcrunch: specifiers: '@pipedream/platform': ^1.5.1 @@ -13347,6 +13355,55 @@ packages: - aws-crt dev: false + /@aws-sdk/client-sso-oidc/3.600.0_tdq3komn4zwyd65w7klbptsu34: + resolution: {integrity: sha512-7+I8RWURGfzvChyNQSyj5/tKrqRbzRl7H+BnTOf/4Vsw1nFOi5ROhlhD4X/Y0QCTacxnaoNcIrqnY7uGGvVRzw==} + engines: {node: '>=16.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 5.2.0 + '@aws-crypto/sha256-js': 5.2.0 + '@aws-sdk/client-sts': 3.600.0 + '@aws-sdk/core': 3.598.0 + '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 + '@aws-sdk/middleware-host-header': 3.598.0 + '@aws-sdk/middleware-logger': 3.598.0 + '@aws-sdk/middleware-recursion-detection': 3.598.0 + '@aws-sdk/middleware-user-agent': 3.598.0 + '@aws-sdk/region-config-resolver': 3.598.0 + '@aws-sdk/types': 3.598.0 + '@aws-sdk/util-endpoints': 3.598.0 + '@aws-sdk/util-user-agent-browser': 3.598.0 + '@aws-sdk/util-user-agent-node': 3.598.0 + '@smithy/config-resolver': 3.0.3 + '@smithy/core': 2.2.3 + '@smithy/fetch-http-handler': 3.2.1 + '@smithy/hash-node': 3.0.2 + '@smithy/invalid-dependency': 3.0.2 + '@smithy/middleware-content-length': 3.0.2 + '@smithy/middleware-endpoint': 3.0.4 + '@smithy/middleware-retry': 3.0.6 + '@smithy/middleware-serde': 3.0.3 + '@smithy/middleware-stack': 3.0.3 + '@smithy/node-config-provider': 3.1.3 + '@smithy/node-http-handler': 3.1.2 + '@smithy/protocol-http': 4.0.3 + '@smithy/smithy-client': 3.1.6 + '@smithy/types': 3.3.0 + '@smithy/url-parser': 3.0.3 + '@smithy/util-base64': 3.0.0 + '@smithy/util-body-length-browser': 3.0.0 + '@smithy/util-body-length-node': 3.0.0 + '@smithy/util-defaults-mode-browser': 3.0.6 + '@smithy/util-defaults-mode-node': 3.0.6 + '@smithy/util-endpoints': 2.0.3 + '@smithy/util-middleware': 3.0.3 + '@smithy/util-retry': 3.0.2 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.3 + transitivePeerDependencies: + - '@aws-sdk/client-sts' + - aws-crt + dev: false + /@aws-sdk/client-sso/3.423.0: resolution: {integrity: sha512-znIufHkwhCIePgaYciIs3x/+BpzR57CZzbCKHR9+oOvGyufEPPpUT5bFLvbwTgfiVkTjuk6sG/ES3U5Bc+xtrA==} engines: {node: '>=14.0.0'} @@ -13582,55 +13639,7 @@ packages: dependencies: '@aws-crypto/sha256-browser': 5.2.0 '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0 - '@aws-sdk/core': 3.598.0 - '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 - '@aws-sdk/middleware-host-header': 3.598.0 - '@aws-sdk/middleware-logger': 3.598.0 - '@aws-sdk/middleware-recursion-detection': 3.598.0 - '@aws-sdk/middleware-user-agent': 3.598.0 - '@aws-sdk/region-config-resolver': 3.598.0 - '@aws-sdk/types': 3.598.0 - '@aws-sdk/util-endpoints': 3.598.0 - '@aws-sdk/util-user-agent-browser': 3.598.0 - '@aws-sdk/util-user-agent-node': 3.598.0 - '@smithy/config-resolver': 3.0.3 - '@smithy/core': 2.2.3 - '@smithy/fetch-http-handler': 3.2.1 - '@smithy/hash-node': 3.0.2 - '@smithy/invalid-dependency': 3.0.2 - '@smithy/middleware-content-length': 3.0.2 - '@smithy/middleware-endpoint': 3.0.4 - '@smithy/middleware-retry': 3.0.6 - '@smithy/middleware-serde': 3.0.3 - '@smithy/middleware-stack': 3.0.3 - '@smithy/node-config-provider': 3.1.3 - '@smithy/node-http-handler': 3.1.2 - '@smithy/protocol-http': 4.0.3 - '@smithy/smithy-client': 3.1.6 - '@smithy/types': 3.3.0 - '@smithy/url-parser': 3.0.3 - '@smithy/util-base64': 3.0.0 - '@smithy/util-body-length-browser': 3.0.0 - '@smithy/util-body-length-node': 3.0.0 - '@smithy/util-defaults-mode-browser': 3.0.6 - '@smithy/util-defaults-mode-node': 3.0.6 - '@smithy/util-endpoints': 2.0.3 - '@smithy/util-middleware': 3.0.3 - '@smithy/util-retry': 3.0.2 - '@smithy/util-utf8': 3.0.0 - tslib: 2.6.3 - transitivePeerDependencies: - - aws-crt - dev: false - - /@aws-sdk/client-sts/3.600.0_dseaa2p5u2yk67qiepewcq3hkq: - resolution: {integrity: sha512-KQG97B7LvTtTiGmjlrG1LRAY8wUvCQzrmZVV5bjrJ/1oXAU7DITYwVbSJeX9NWg6hDuSk0VE3MFwIXS2SvfLIA==} - engines: {node: '>=16.0.0'} - dependencies: - '@aws-crypto/sha256-browser': 5.2.0 - '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0 + '@aws-sdk/client-sso-oidc': 3.600.0_tdq3komn4zwyd65w7klbptsu34 '@aws-sdk/core': 3.598.0 '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 '@aws-sdk/middleware-host-header': 3.598.0 @@ -13669,7 +13678,6 @@ packages: '@smithy/util-utf8': 3.0.0 tslib: 2.6.3 transitivePeerDependencies: - - '@aws-sdk/client-sso-oidc' - aws-crt dev: false @@ -18016,7 +18024,7 @@ packages: '@aws-sdk/client-sns': 3.423.0 '@aws-sdk/client-sqs': 3.423.0 '@aws-sdk/client-ssm': 3.423.0 - '@aws-sdk/client-sts': 3.600.0_dseaa2p5u2yk67qiepewcq3hkq + '@aws-sdk/client-sts': 3.600.0 '@aws-sdk/s3-request-presigner': 3.609.0 '@pipedream/helper_functions': 0.3.12 '@pipedream/platform': 1.6.6