Skip to content

Commit ee00be3

Browse files
[IMPROVEMENT] Aircall - Improve phone number & email handling (#16060)
* [Enhancement] Update Create Contact action to refine phone number handling and improve descriptions * [Enhancement] Update phone number handling in Create Contact action * Add pnpm-lock.yaml * [Enhancement] Refine email handling in Create Contact action * Update package.json * [Enhancement] Handle empty case for phoneNumbers and emails --------- Co-authored-by: Danny Roosevelt <[email protected]>
1 parent 17e5afe commit ee00be3

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

components/aircall/actions/create-contact/create-contact.mjs

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,64 @@ import common from "../common/common-create-update.mjs";
33
export default {
44
...common,
55
name: "Create Contact",
6-
description: "Create a contact in Aircall. [See the documentation](https://developer.aircall.io/api-references/#create-a-contact)",
6+
description:
7+
"Create a contact in Aircall. [See the documentation](https://developer.aircall.io/api-references/#create-a-contact)",
78
key: "aircall-create-contact",
8-
version: "0.0.1",
9+
version: "0.0.2",
910
type: "action",
1011
props: {
1112
...common.props,
1213
emails: {
1314
type: "string[]",
1415
label: "Emails",
15-
description: "Array of email address objects (max 20). Each should contain `label` and `value`. If a string is provided, it will be used as both the label and value.",
16+
description:
17+
"Array of email address objects (max 20). Each should contain `label` and `value`. If a string is provided, it will be used as both the label and value. For example, `{{ [{\"label\": \"Work\", \"value\": \"[email protected]\"}] }}`, or `{{ [\"[email protected]\"] }}`",
1618
optional: true,
1719
},
1820
phoneNumbers: {
1921
type: "string[]",
2022
label: "Phone Numbers",
21-
description: "Array of phone number objects (max 20). Each should contain `label` and `value`. If a string is provided, it will be used as both the label and value.",
23+
description:
24+
"Array of phone number objects (max 20). Each should contain `label` and `value`. If a string is provided, it will be used as both the label and value. For example, `{{ [{\"label\": \"Work\", \"value\": \"+1 812-641-5139\"}] }}`, or `{{ [\"+1 812-641-5139\"] }}`",
2225
},
2326
},
2427
async run({ $ }) {
28+
const refinedPhoneNumbers = (this.phoneNumbers || []).map((item) => {
29+
if (typeof item === "object" && item !== null) {
30+
return item;
31+
}
32+
33+
return {
34+
label: item,
35+
value: item,
36+
};
37+
});
38+
const refinedEmails = (this.emails || []).map((item) => {
39+
if (typeof item === "object" && item !== null) {
40+
return item;
41+
}
42+
43+
return {
44+
label: item,
45+
value: item,
46+
};
47+
});
48+
2549
const data = {
2650
...this.getCommonData(),
27-
emails: this.emails,
28-
phone_numbers: this.phoneNumbers,
51+
emails: refinedEmails,
52+
phone_numbers: refinedPhoneNumbers,
2953
};
54+
3055
const response = await this.aircall.createContact({
3156
$,
3257
data,
3358
});
3459

35-
$.export("$summary", `Successfully created contact (ID: ${response?.contact?.id})`);
60+
$.export(
61+
"$summary",
62+
`Successfully created contact (ID: ${response?.contact?.id})`,
63+
);
3664

3765
return response;
3866
},

components/aircall/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/aircall",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Pipedream Aircall Components",
55
"main": "aircall.app.mjs",
66
"keywords": [

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)