Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Components - pidj #11962

Merged
merged 7 commits into from
Jul 12, 2024
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
172 changes: 172 additions & 0 deletions components/pidj/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import { TIMEZONE_OPTIONS } from "../../common/constants.mjs";
import pidj from "../../pidj.app.mjs";

export default {
key: "pidj-create-contact",
name: "Create Contact",
description: "Initiates a process to add a new contact to your Pidj account. [See the documentation](https://pidj.co/wp-content/uploads/2023/06/Pidj-API-Technical-Document-v3-1.pdf).",
version: "0.0.1",
type: "action",
props: {
pidj,
phoneNumber: {
type: "string",
label: "Phone Number",
description: "Phone number for the contact. This must be in E.164 format. **e.g., +18885552222**",
},
emailAddress: {
type: "string",
label: "Email Address",
description: "The contact's email address.",
optional: true,
},
firstName: {
type: "string",
label: "First Name",
description: "The contact's first name.",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "The contact's last name.",
optional: true,
},
businessName: {
type: "string",
label: "Business Name",
description: "The contact's business name.",
optional: true,
},
displayName: {
type: "string",
label: "Display Name",
description: "The contact's display name, if present, and different from first and last name.",
optional: true,
},
groupId: {
propDefinition: [
pidj,
"groupId",
],
optional: true,
},
timezone: {
type: "string",
label: "Timezone",
description: "Timezone identifier for the contact. If omitted, this will default to the account value.",
options: TIMEZONE_OPTIONS,
optional: true,
},
externalId: {
type: "string",
label: "External Id",
description: "The external ID of the contact from your own system. This may be used in any enabled integrations to cross-identify the contact record.",
optional: true,
},
homeAddressStreet1: {
type: "string",
label: "Home Street 1",
description: "The home street address 1.",
optional: true,
},
homeAddressStreet2: {
type: "string",
label: "Home Street 2",
description: "The home street address 2.",
optional: true,
},
homeAddressCity: {
type: "string",
label: "Home City",
description: "The home city address.",
optional: true,
},
homeAddressState: {
type: "string",
label: "Home State",
description: "The home state address. Must be the standard 2 character abbreviation (**ANSI2-letter** or **USPS**). Any other values will be discarded. [See further information](https://en.wikipedia.org/wiki/List_of_U.S._state_abbreviations).",
optional: true,
},
homeAddressPostal: {
type: "string",
label: "Home Postal",
description: "Valid 5 or 10 digit zipcode (US addresses). British, Canadian, and Australian postal codes also supported.",
optional: true,
},
homeAddressCountry: {
type: "string",
label: "Home Country",
description: "Must be either **ISO 3166-1 alpha-2** or **ISO 3166-1 alpha-3**. Any other values will be discarded. [See further information](https://en.wikipedia.org/wiki/ISO_3166-1).",
optional: true,
},
businessAddressStreet1: {
type: "string",
label: "Business Street 1",
description: "The business street address 1.",
optional: true,
},
businessAddressStreet2: {
type: "string",
label: "Business Street 2",
description: "The business street address 2.",
optional: true,
},
businessAddressCity: {
type: "string",
label: "Business City",
description: "The business city address.",
optional: true,
},
businessAddressState: {
type: "string",
label: "Business State",
description: "The business state address. Must be the standard 2 character abbreviation (**ANSI2-letter** or **USPS**). Any other values will be discarded. [See further information](https://en.wikipedia.org/wiki/List_of_U.S._state_abbreviations).",
optional: true,
},
businessAddressPostal: {
type: "string",
label: "Business Postal",
description: "Valid 5 or 10 digit zipcode (US addresses). British, Canadian, and Australian postal codes also supported.",
optional: true,
},
businessAddressCountry: {
type: "string",
label: "Business Country",
description: "Must be either **ISO 3166-1 alpha-2** or **ISO 3166-1 alpha-3**. Any other values will be discarded. [See further information](https://en.wikipedia.org/wiki/ISO_3166-1).",
optional: true,
},
},
async run({ $ }) {
const response = await this.pidj.addContact({
$,
data: {
phone_number: this.phoneNumber,
email_address: this.emailAddress,
first_name: this.firstName,
last_name: this.lastName,
business_name: this.businessName,
display_name: this.displayName,
group: this.groupId,
timezone: this.timezone,
external_id: this.externalId,
addresses: {
home_street_1: this.homeAddressStreet1,
home_street_2: this.homeAddressStreet2,
home_city: this.homeAddressCity,
home_state: this.homeAddressState,
home_postal: this.homeAddressPostal,
home_country: this.homeAddressCountry,
business_street_1: this.businessAddressStreet1,
business_street_2: this.businessAddressStreet2,
business_city: this.businessAddressCity,
business_state: this.businessAddressState,
business_postal: this.businessAddressPostal,
business_country: this.businessAddressCountry,
},
},
});
$.export("$summary", `Successfully added a new contact with Id: ${response.id}`);
return response;
},
};
57 changes: 57 additions & 0 deletions components/pidj/actions/initiate-survey/initiate-survey.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { ConfigurationError } from "@pipedream/platform";
import pidj from "../../pidj.app.mjs";

export default {
key: "pidj-initiate-survey",
name: "Initiate Survey",
description: "Triggers a pre-configured text survey to a specific contact. Requires the contact's information and the survey ID. [See the documentation](https://pidj.co/wp-content/uploads/2023/06/Pidj-API-Technical-Document-v3-1.pdf).",
version: "0.0.1",
type: "action",
props: {
pidj,
surveyId: {
propDefinition: [
pidj,
"surveyId",
],
},
contactId: {
propDefinition: [
pidj,
"contactId",
],
},
fromNumber: {
propDefinition: [
pidj,
"fromNumber",
],
optional: true,
},
groupId: {
propDefinition: [
pidj,
"groupId",
],
optional: true,
},
},
async run({ $ }) {
if ((!this.fromNumber && !this.groupId) || (this.fromNumber && this.groupId)) {
throw new ConfigurationError("You must provide either From Number or Group Id.");
}

const response = await this.pidj.triggerSurvey({
$,
data: {
survey_id: this.surveyId,
contact_id: this.contactId,
from_number: this.fromNumber,
group_id: this.groupId,
},
});

$.export("$summary", `Successfully initiated survey for contact ${this.contactId}`);
return response;
},
luancazarine marked this conversation as resolved.
Show resolved Hide resolved
};
44 changes: 44 additions & 0 deletions components/pidj/actions/send-message/send-message.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { ConfigurationError } from "@pipedream/platform";
import pidj from "../../pidj.app.mjs";

export default {
key: "pidj-send-message",
name: "Send Message",
description: "Sends a text message to a specified phone number from your pidj account. [See the documentation](https://pidj.co/wp-content/uploads/2023/06/Pidj-API-Technical-Document-v3-1.pdf).",
version: "0.0.1",
type: "action",
props: {
pidj,
groupId: {
propDefinition: [
pidj,
"groupId",
],
},
toNumber: {
propDefinition: [
pidj,
"toNumber",
],
},
textBody: {
type: "string",
label: "Text Body",
description: "The text to send. Message lengths greater than 1,600 characters will be truncated. Messages with emoji and special characters may have a smaller limit due to encoding requirements. [See Pidj FAQ for details](https://pidjco.gopidj.com/faq).",
},
},
async run({ $ }) {
const response = await this.pidj.sendMessage({
$,
data: {
group_id: this.groupId,
to_number: this.toNumber,
text_body: this.textBody,
},
});
if (response.status != "success") throw new ConfigurationError(response.message);

$.export("$summary", `Message successfully sent to ${this.toNumber}`);
return response;
},
luancazarine marked this conversation as resolved.
Show resolved Hide resolved
};
Loading
Loading