-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New Components - help_scout #14617
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merged
Merged
New Components - help_scout #14617
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}, | ||
}; |
203 changes: 203 additions & 0 deletions
203
components/help_scout/actions/create-customer/create-customer.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
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, | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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, | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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, | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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, | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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, | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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({ $ }) { | ||
try { | ||
const address = cleanObject({ | ||
city: this.addressCity, | ||
state: this.addressState, | ||
postalCode: this.addressPostalCode, | ||
country: this.addressCountry, | ||
lines: parseObject(this.addressLines), | ||
properties: parseObject(this.properties), | ||
}); | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const 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."); | ||
} | ||
|
||
const response = await this.helpScout.createCustomer({ | ||
$, | ||
data, | ||
}); | ||
|
||
$.export("$summary", "Successfully created the new customer."); | ||
return response; | ||
|
||
} catch ({ response }) { | ||
throw new ConfigurationError(response.data.message); | ||
} | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const PHOTO_TYPE_OPTIONS = [ | ||
"unknown", | ||
"gravatar", | ||
"twitter", | ||
"facebook", | ||
"googleprofile", | ||
"googleplus", | ||
"linkedin", | ||
"instagram", | ||
]; | ||
|
||
export const GENDER_OPTIONS = [ | ||
"male", | ||
"female", | ||
"unknown", | ||
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.