Properly mapping fields from OpenPhone module

We use the OpenPhone module to capture new customer detail i.e. the module triggers based on either a new contact or updated contact in OpenPhone. Coming out of OpenPhone we are simply trying to isolate essentially 5 to 7 separate fields, including: first name, last name to begin with and then in the nested ‘Fields’ collection: phone, Email, tags (nested array in between ), source, address. Additionally an array for notes as well.

OpenPhone triggered output

[
        {
            "id": "EV84620e116d524783bea97f782d0135d3",
            "object": "event",
            "createdAt": "2024-04-28T01:52:33.229Z",
            "apiVersion": "v3",
            "type": "contact.updated",
            "data": {
                "object": {
                    "id": "CT662c17a6b69fdfddd80f0fb4",
                    "object": "contact",
                    "firstName": "Jonny",
                    "lastName": "Appleseed",
                    "company": "ACME Orchards 44",
                    "role": "Master Gardener",
                    "fields": {
                        "Phone": "+12345678902",
                        "Email": "[spoiler]chris@bbb.com[/spoiler]",
                        "Tags": [
                            "Customer",
                            "OpenPhone"
                        ],
                        "Source": "Web",
                        "Address": "[spoiler]95 N 100 W, W[/spoiler]"
                    },
                    "notes": [
                        {
                            "text": "Testing",
                            "enrichment": null,
                            "createdAt": "2024-04-27T01:27:09.291Z",
                            "updatedAt": "2024-04-27T06:02:53.556Z",
                            "userId": "USGGH7a2Td"
                        },
                        {
                            "text": "Test",
                            "enrichment": null,
                            "createdAt": "2024-04-27T01:27:33.878Z",
                            "updatedAt": "2024-04-27T06:02:52.223Z",
                            "userId": "USGGH7a2Td"
                        }
                    ],
                    "sharedWith": [
                        "USGGH7a2Td",
                        "ORlpK27be1"
                    ],
                    "clientId": "09e1ad8c-9d63-4a91-948b-548bab3a37c8",
                    "createdAt": "2024-04-26T21:08:10.720Z",
                    "updatedAt": "2024-04-28T01:52:33.211Z",
                    "userId": "USGGH7a2Td"
                }
            }
        }
    ]

After using the two array function via the iteration tool… Were able to see that we have as many as five bundles each with an appropriate key name and value etc. but to no avail after using the aggregator tool, we are not able to have just a simple list of the appropriate field name and its value to choose from and send it on elsewhere… I’m missing something very simple and we’ve spent three very long days reading, viewing, testing etc.… we are new to Make. ’ Have used Zappier minimally.

ITERATED Output

[
        {
            "key": "Phone",
            "value": "+12345678902",
            "__IMTINDEX__": 1,
            "__IMTLENGTH__": 5
        },
        {
            "key": "Email",
            "value": "[spoiler]chris@bbb.com[/spoiler]",
            "__IMTINDEX__": 2,
            "__IMTLENGTH__": 5
        },
        {
            "key": "Tags",
            "value": [
                "Customer",
                "OpenPhone"
            ],
            "__IMTINDEX__": 3,
            "__IMTLENGTH__": 5
        },
        {
            "key": "Source",
            "value": "Web",
            "__IMTINDEX__": 4,
            "__IMTLENGTH__": 5
        },
        {
            "key": "Address",
            "value": "[spoiler]95 N 100 W, W[/spoiler]",
            "__IMTINDEX__": 5,
            "__IMTLENGTH__": 5
        }
    ]

Ideally it seems to make sense that I should be able to set multiple variables Perhaps… Or use a get ( map ( function… What also confuses this is that there is a nested array within the fields collection for any tags that are assigned in open phone… We would like to preserve those tags in someway as well and pass them on… Along with the array for the notes.

Perhaps there’s not a better way to approach this and what we are doing however any insight and correction here would be great…!! Thank you in advance :face_with_spiral_eyes:

If we throw in an array aggregator after the iterator tool… We still are not able to see selectable field choices for phone, email, source, address… Just the single value for the array.

Welcome to the Make community!

Your OpenPhone output fields looks like a collection, you shouldn’t need to convert it to an array just to map the sub-properties.

So delete the iterator and just directly reference

{{ 1.data.object.fields.Phone }}

3 Likes

That is fantastic and wow were we making it too hard!! Thank you thank you. I’m attaching the following screenshot and text for the output of the set multiple variables tool… And my question is now for the tags and the notes… Any thoughts?

From OpenPhone module

[
    {
        "id": "EV64fe5deafec74e25b0b9016470db3304",
        "object": "event",
        "createdAt": "2024-04-28T15:54:12.707Z",
        "apiVersion": "v3",
        "type": "contact.updated",
        "data": {
            "object": {
                "id": "CT662c17a6b69fdfddd80f0fb4",
                "object": "contact",
                "firstName": "Jonny",
                "lastName": "Appleseed",
                "company": "ACME Orchards 45",
                "role": "Master Gardener",
                "fields": {
                    "Phone": "+12345678902",
                    "Email": "chris@.com",
                    "Tags": [
                        "Customer",
                        "OpenPhone"
                    ],
                    "Source": "Web",
                    "Address": "95 N 10"
                },
                "notes": [
                    {
                        "text": "Testing",
                        "enrichment": null,
                        "createdAt": "2024-04-27T01:27:09.291Z",
                        "updatedAt": "2024-04-27T06:02:53.556Z",
                        "userId": "USGGH7a2Td"
                    },
                    {
                        "text": "Test",
                        "enrichment": null,
                        "createdAt": "2024-04-27T01:27:33.878Z",
                        "updatedAt": "2024-04-27T06:02:52.223Z",
                        "userId": "USGGH7a2Td"
                    }
                ],
                "sharedWith": [
                    "USGGH7a2Td",
                    "ORlpK27be1"
                ],
                "clientId": "52a52afb-fb99-4552-8910-a5bddc3539e9",
                "createdAt": "2024-04-26T21:08:10.720Z",
                "updatedAt": "2024-04-28T15:54:12.697Z",
                "userId": "USGGH7a2Td"
            }
        }
    }
]

Specified the variables as follows:

{{ 1.data.object.firstName}}

{{ 1.data.object.lastName }}

{{ 1.data.object.fields.Phone }}

{{ 1.data.object.fields.Email }}

{{ 1.data.object.fields.Tags }}

{{ 1.data.object.fields.Source }}

{{ 1.data.object.fields.Address }}

{{ 1.data.object.fields.notes.Text }}

Results

[
    {
        "variable_firstName": "Jonny",
        "variable_lastName": "Appleseed",
        "variablePhone": "+12345678902",
        "variableEmail": "chris@bbb.com",
        "variableTags": [
            "Customer",
            "OpenPhone"
        ],
        "variableSource": "Web",
        "variableAddress": "95 N 10",
        "variableNotes": null
    }
]

Tags is a simple array (containing only primitive data types like strings).

So you can just use the built-in function join

{{ join(1.data.object.fields.Tags; ", " }}

For notes array, it’s containing a complex data structure (collection/object) of notes.

So before you can join them, you’ll need to select the key containing the value you want to join.

This can be done with the built-in function map

{{ join(map(1.data.object.fields.Notes; "text"); ", " }}

For more information, see

Links

Here are some useful links and guides to help you get started and learn more on how to use the Make platform, apps, and app modules —

General

Help Center Basics

Articles & Videos

2 Likes

I wonder why the fields collection was being mapped as an array here? Probably because the OpenPhone Make app doesn’t have a proper interface defined. This led you astray @letadventurebegin unfortunately. You also stumbled upon the fact that a collection can be iterated as well as an array and in a collection each key/value will be iterated upon thus leading to your initial output that you were getting. An iterator will then execute the subsequent modules based on the number of items in the array/collection so that’s probably not what you wanted at all.

Remember that:

  1. an iterator creates a loop for all subsequent modules along the path (which can be filtered as well to prevent execution for one or more of the bundles coming out of the iterators

  2. an aggregator will collect the bundles into one or more new bundles depending on the number of bundles genereated in the source module configured in an aggregator. There are many aggregators in Make and they all have one thing in common – a source module that should be configured.

When you don’t need iteration or aggregation you can map the specific fields into subsequent module from each module or manipulate the underlying array data with array functions as @samliew illustrated so well. The map() function is one such function that allows you to grab data from an array based on a certain key or filters an array based on the values of certain keys. Then you can convert the resulting array into strings with join().


Alex Sirota
Director of NewPath Consulting - we are Make Heroes!
My Solutions on Make Community

2 Likes