Skip to content

OpenPhone Usability Audit #16165

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

Merged
merged 4 commits into from
Apr 7, 2025
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
2 changes: 1 addition & 1 deletion components/bettercontact/bettercontact.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/bytebot/bytebot.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/notiff/notiff.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "openphone-create-contact",
name: "Create Contact",
description: "Create a new contact in OpenPhone. [See the documentation](https://www.openphone.com/docs/api-reference/contacts/create-a-contact)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
openphone,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import openphone from "../../openphone.app.mjs";

export default {
key: "openphone-list-phone-numbers",
name: "List Phone Numbers",
description: "Retrieve the list of phone numbers and users associated with your OpenPhone workspace. [See the documentation](https://www.openphone.com/docs/mdx/api-reference/phone-numbers/list-phone-numbers)",
version: "0.0.1",
type: "action",
props: {
openphone,
},
async run({ $ }) {
const { data } = await this.openphone.listPhoneNumbers({
$,
});
if (data?.length) {
$.export("$summary", `Successfully retrieved ${data.length} phone number${data.length === 1
? ""
: "s"}`);
}
return data;
},
};
44 changes: 15 additions & 29 deletions components/openphone/actions/send-message/send-message.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { ConfigurationError } from "@pipedream/platform";
import openphone from "../../openphone.app.mjs";

export default {
key: "openphone-send-message",
name: "Send a Text Message via OpenPhone",
name: "Send a Text Message",
description: "Send a text message from your OpenPhone number to a recipient. [See the documentation](https://www.openphone.com/docs/api-reference/messages/send-a-text-message)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
openphone,
Expand All @@ -27,31 +26,18 @@ export default {
},
},
async run({ $ }) {
try {
const response = await this.openphone.sendTextMessage({
$,
data: {
content: this.content,
from: this.from,
to: [
this.to,
],
setInboxStatus: "done",
},
});
$.export("$summary", `Successfully sent message to ${this.to}`);
return response;

} catch ({ response }) {
let errorMessage = "";

if (response.data.errors) {
errorMessage = `Prop: ${response.data.errors[0].path} - ${response.data.errors[0].message}`;
} else {
errorMessage = response.data.message;
}

throw new ConfigurationError(errorMessage);
}
const response = await this.openphone.sendTextMessage({
$,
data: {
content: this.content,
from: this.from,
to: [
this.to,
],
setInboxStatus: "done",
},
});
$.export("$summary", `Successfully sent message to ${this.to}`);
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ export default {
key: "openphone-update-contact",
name: "Update Contact",
description: "Update an existing contact on OpenPhone. [See the documentation](https://www.openphone.com/docs/api-reference/contacts/update-a-contact-by-id)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
openphone,
contactId: {
type: "string",
label: "Contact ID",
description: "The unique identifier of the contact.",
description: "The unique identifier of the contact",
},
firstName: {
propDefinition: [
Expand Down
52 changes: 35 additions & 17 deletions components/openphone/openphone.app.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { axios } from "@pipedream/platform";
import {
axios, ConfigurationError,
} from "@pipedream/platform";
import Bottleneck from "bottleneck";
const limiter = new Bottleneck({
minTime: 100, // 10 requests per seconds (https://www.openphone.com/docs/mdx/api-reference/rate-limits)
maxConcurrent: 1,
});
const axiosRateLimiter = limiter.wrap(axios);

export default {
type: "app",
Expand All @@ -10,51 +18,53 @@ export default {
description: "The sender's phone number. Can be either your OpenPhone phone number ID or the full phone number in E.164 format.",
async options() {
const { data } = await this.listPhoneNumbers();
return data.map(({
return data?.map(({
id: value, name, formattedNumber,
}) => ({
label: `${name} - ${formattedNumber}`,
label: name && formattedNumber
? `${name} - ${formattedNumber}`
: value,
value,
}));
})) || [];
},
},
firstName: {
type: "string",
label: "First Name",
description: "The contact's first name.",
description: "The contact's first name",
},
lastName: {
type: "string",
label: "Last Name",
description: "The contact's last name.",
description: "The contact's last name",
optional: true,
},
company: {
type: "string",
label: "Company",
description: "The contact's company name.",
description: "The contact's company name",
optional: true,
},
role: {
type: "string",
label: "Role",
description: "The contact's role.",
description: "The contact's role",
optional: true,
},
emails: {
type: "string[]",
label: "Emails",
description: "Array of objects of contact's emails. **Example:** `{\"name\": \"Company Email\", \"value\": \"[email protected]\"}`.",
description: "Array of objects of contact's emails. **Example:** `{\"name\": \"Company Email\", \"value\": \"[email protected]\"}`",
},
phoneNumbers: {
type: "string[]",
label: "Phone Numbers",
description: "Array of objects of contact's phone numbers. **Example:** `{\"name\": \"Company Phone\", \"value\": \"+12345678901\"}`.",
description: "Array of objects of contact's phone numbers. **Example:** `{\"name\": \"Company Phone\", \"value\": \"+12345678901\"}`",
},
customFields: {
type: "string[]",
label: "Custom Fields",
description: "Array of objects of custom fields for the contact. **Example:** `{\"key\": \"inbound-lead\", \"value\": \"[\"option1\", \"option2\"]\"}`.",
description: "Array of objects of custom fields for the contact. **Example:** `{\"key\": \"inbound-lead\", \"value\": [\"option1\", \"option2\"]}`",
},
},
methods: {
Expand All @@ -66,14 +76,22 @@ export default {
Authorization: `${this.$auth.api_key}`,
};
},
_makeRequest({
async _makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: this._baseUrl() + path,
headers: this._headers(),
...opts,
});
try {
return await axiosRateLimiter($, {
url: this._baseUrl() + path,
headers: this._headers(),
...opts,
});
} catch ({ response }) {
const errorMessage = response?.data?.errors
? `Prop: ${response.data.errors[0].path} - ${response.data.errors[0].message}`
: response?.data?.message;

throw new ConfigurationError(errorMessage);
}
},
listPhoneNumbers(opts = {}) {
return this._makeRequest({
Expand Down
5 changes: 3 additions & 2 deletions components/openphone/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/openphone",
"version": "0.1.0",
"version": "0.2.0",
"description": "Pipedream OpenPhone Components",
"main": "openphone.app.mjs",
"keywords": [
Expand All @@ -13,6 +13,7 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
"@pipedream/platform": "^3.0.3",
"bottleneck": "^2.19.5"
}
}
4 changes: 2 additions & 2 deletions components/openphone/sources/common/base.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ export default {
],
type: "string[]",
label: "Resource IDs",
description: "The unique identifiers of phone numbers associated with the webhook.",
description: "The IDs of the incoming or outgoing phone numbers to retrieve events for. Use the List Phone Numbers action to retrieve information about phone numbers.",
optional: true,
},
label: {
type: "string",
label: "Label",
description: "Webhook's label",
description: "A label to identify the webhook",
optional: true,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import sampleEmit from "./test-event.mjs";
export default {
...common,
key: "openphone-new-call-recording-completed-instant",
name: "New Call Recording Completed",
name: "New Call Recording Completed (Instant)",
description: "Emit new event when a call recording has finished.",
version: "0.0.1",
version: "0.0.2",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "openphone-new-incoming-call-completed-instant",
name: "New Incoming Call Completed (Instant)",
description: "Emit new event when an incoming call is completed, including calls not picked up or voicemails left.",
version: "0.0.1",
version: "0.0.2",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "openphone-new-outgoing-call-completed-instant",
name: "New Outgoing Call Completed (Instant)",
description: "Emit new event when an outgoing call has ended.",
version: "0.0.1",
version: "0.0.2",
type: "source",
dedupe: "unique",
methods: {
Expand Down
2 changes: 1 addition & 1 deletion components/teltel/teltel.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
13 changes: 8 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading