Skip to content

Commit ac29641

Browse files
committed
openphone init
1 parent d34773c commit ac29641

File tree

8 files changed

+685
-6
lines changed

8 files changed

+685
-6
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import openphone from "../../openphone.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "openphone-create-contact",
6+
name: "Create Contact",
7+
description: "Create a new contact in OpenPhone. [See the documentation](https://www.openphone.com/docs/api-reference/contacts/create-a-contact)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
openphone,
12+
firstName: {
13+
type: "string",
14+
label: "First Name",
15+
description: "The contact's first name.",
16+
},
17+
lastName: {
18+
type: "string",
19+
label: "Last Name",
20+
description: "The contact's last name.",
21+
optional: true,
22+
},
23+
company: {
24+
type: "string",
25+
label: "Company",
26+
description: "The contact's company name.",
27+
optional: true,
28+
},
29+
role: {
30+
type: "string",
31+
label: "Role",
32+
description: "The contact's role.",
33+
optional: true,
34+
},
35+
emails: {
36+
type: "string[]",
37+
label: "Emails",
38+
description: "Array of contact's emails.",
39+
optional: true,
40+
},
41+
phoneNumbers: {
42+
type: "string[]",
43+
label: "Phone Numbers",
44+
description: "Array of contact's phone numbers.",
45+
optional: true,
46+
},
47+
customFields: {
48+
type: "string[]",
49+
label: "Custom Fields",
50+
description: "Array of custom fields for the contact.",
51+
optional: true,
52+
},
53+
},
54+
async run({ $ }) {
55+
const data = {
56+
firstName: this.firstName,
57+
lastName: this.lastName,
58+
company: this.company,
59+
role: this.role,
60+
emails: this.emails,
61+
phoneNumbers: this.phoneNumbers,
62+
customFields: this.customFields,
63+
};
64+
65+
const response = await this.openphone.createContact(data);
66+
67+
$.export("$summary", `Successfully created contact with ID: ${response.id}`);
68+
return response;
69+
},
70+
};
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import openphone from "../../openphone.app.mjs";
2+
3+
export default {
4+
key: "openphone-update-contact",
5+
name: "Update Contact",
6+
description: "Update an existing contact on OpenPhone. [See the documentation](https://www.openphone.com/docs/api-reference/contacts/update-a-contact-by-id)",
7+
version: "0.0.{{ts}}",
8+
type: "action",
9+
props: {
10+
openphone,
11+
contactId: {
12+
propDefinition: [
13+
openphone,
14+
"contactId",
15+
],
16+
},
17+
firstName: {
18+
propDefinition: [
19+
openphone,
20+
"firstName",
21+
],
22+
optional: true,
23+
},
24+
lastName: {
25+
propDefinition: [
26+
openphone,
27+
"lastName",
28+
],
29+
optional: true,
30+
},
31+
company: {
32+
propDefinition: [
33+
openphone,
34+
"company",
35+
],
36+
optional: true,
37+
},
38+
role: {
39+
propDefinition: [
40+
openphone,
41+
"role",
42+
],
43+
optional: true,
44+
},
45+
emails: {
46+
propDefinition: [
47+
openphone,
48+
"emails",
49+
],
50+
optional: true,
51+
},
52+
phoneNumbers: {
53+
propDefinition: [
54+
openphone,
55+
"phoneNumbers",
56+
],
57+
optional: true,
58+
},
59+
customFields: {
60+
propDefinition: [
61+
openphone,
62+
"customFields",
63+
],
64+
optional: true,
65+
},
66+
},
67+
async run({ $ }) {
68+
const data = {
69+
firstName: this.firstName,
70+
lastName: this.lastName,
71+
company: this.company,
72+
role: this.role,
73+
emails: this.emails,
74+
phoneNumbers: this.phoneNumbers,
75+
customFields: this.customFields,
76+
};
77+
78+
const response = await this.openphone.updateContact(this.contactId, data);
79+
80+
$.export("$summary", `Successfully updated contact with ID ${this.contactId}`);
81+
return response;
82+
},
83+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import openphone from "../../openphone.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "openphone-send-message",
6+
name: "Send a Text Message via OpenPhone",
7+
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)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
openphone,
12+
from: {
13+
propDefinition: [
14+
openphone,
15+
"from",
16+
],
17+
},
18+
to: {
19+
propDefinition: [
20+
openphone,
21+
"to",
22+
],
23+
},
24+
content: {
25+
propDefinition: [
26+
openphone,
27+
"content",
28+
],
29+
},
30+
userId: {
31+
propDefinition: [
32+
openphone,
33+
"userId",
34+
],
35+
optional: true,
36+
},
37+
setInboxStatus: {
38+
propDefinition: [
39+
openphone,
40+
"setInboxStatus",
41+
],
42+
optional: true,
43+
},
44+
},
45+
async run({ $ }) {
46+
const response = await this.openphone.sendTextMessage({
47+
from: this.from,
48+
to: this.to,
49+
content: this.content,
50+
userId: this.userId,
51+
setInboxStatus: this.setInboxStatus,
52+
});
53+
$.export("$summary", `Successfully sent message to ${this.to}`);
54+
return response;
55+
},
56+
};

0 commit comments

Comments
 (0)