JSONPath

From Planfix
Jump to: navigation, search

Use the dedicated online service to debug and fix parsing errors: JSONPath Online Evaluator

You can parse incoming emails or webhooks in Planfix with JSON. Emails sent to Planfix can be parsed using JSON. JavaScript Object Notation is a format for storing and exchanging information available as human-readable text.  There are two main elements in a JSON object: the key and the value.

Example:

{"city":"New York", "country":"United States"}
  • keys — city and country;
  • values — New York and United States

Planfix can parse emails in this format and add the necessary data into info blocks using the JsonPath library. Note: If you use a function when parsing, make sure that you insert parenthesis at the end, otherwise the function will not work.

H5gE8u.jpg

Example №1

Sending an Email with JSON Format to Planfix

  • As an example, we'll use the following JSON:

{

"firstName": "Denis",
"lastName": "Evans",

"address": {

"streetAddress": "1109 SW 12th St",
"city": "Newport",
"postalCode": 97365

},

"phoneNumbers": [

"1-211-906-4147"

]

}

  • Let's say we need the following data from the JSON:

{

"firstName": "Denis",
"lastName": "Evans",

"address": {

"streetAddress": "1109 SW 12th St",
"city": "Newport",
"postalCode": 97365

},

"phoneNumbers": [

"1-211-906-4147",

}

 

  • We would configure the following rule for processing emails:

BGQzWr.jpg

  • Next, we create a new customer using the template, indicate which infoblocks to set from which fields, and add the contact to the task created from the email:

dL1P6b.jpg

  • As a result, the necessary data from the email in JSON format was transferred to Planfix:

NtRliu.jpg

Example №2

Adding JSON parameters to Planfix data tags

For this example, we'll use JSON from a product order in an online store. The data required for adding analytics is highlighted in red:

{

"site": "mysite.shop",
"name": "Denis Evans",
"id": "6598634",
"date": "30.11.2024 09:16:05",
"status": "In progress",
"email": "techT7@gmail.com",
"phone": "+1 211 906-4147",
"address": "1109 SW 12th St1",
"price_total": "466.45",
"item_order": [

{

"sku": "598623",
"name": Cobalt drill bit set 29pc",
"barcode": "596325689126",
"price": "29.99",
"quantity": 5

},
{

"sku": "589624",
"name": "High torque driver",
"barcode": "5963256858963",
"price": "230.00",
"quantity": 1

},
{

"sku": "579824",
"name": "Half inch ratchet 120 tooth",
"barcode": "5963256889634",
"price": "43.25",
"quantity": 2

}
]

}

  • Setting up a separate rule for email tasks. Parsing JSON:

4bwSgN.jpg

  • Create a new task and notify the required employee of its creation:

KxwRR2.jpg

  • Adding data tags to the created task. Note: It's important to specify the parameter Add as many lines as there are values in the infoblock to ensure that all values are added to the data tags.

k56IP5.jpg

  • As a result, the task displays the notification and data tags:

ptZGmD.jpg

LKfSAe.jpg

Go To