devigner
devigner

Reputation: 152

Data is coming in as a JSON object, how to parse?

I'm trying to build a Zap that takes customer feedback via Unbird and sends a Slack messages that would make sense to anyone at my org who reads it.

Currently getting customer feedback data from Unbird into Zapier and it looks something like a javascript object, like this:

{
  0: website
  1: [email protected]
  2: Jon
  3: Smith
  4: You guys have a great website, but should add dark mode.
}

And I want to send a message to Slack that says something like

Jon Smith ([email protected]) just sent you Website feedback: You guys have a great website, but should add dark mode.

I can select and send the "entry property values" to Slack, it looks like this:

website, [email protected], Jon, Smith, You guys have a great website, but should add dark mode.

I tried using Zapier's Split function with a comma as the separator, but that doesn't successfully split it. I tried using a Zapier code snippet to isolate individual values, but when I do myobj.0 that doesn't work. Is this maybe an array? I don't think you can even have numbers for key names in js. It's been way too long since I did any coding.

I tried using JSON.stringify to make it a string, but in Zapier code snippets the output has to be an object, so I'm stuck with a stupid object again! I just want text, I could work with text, or some way to call individual values in the object for later use.

Help!

Upvotes: 0

Views: 233

Answers (1)

Owari Jules
Owari Jules

Reputation: 126

If the customer feedback is already coming in as an object where those keys are separated by a comma, you just need to return the output and this should split into individual entries for each value.

In your case -

var obj = {  0: "website", 1:"[email protected]", 2: "Jon", 3: "Smith",4:"You guys have a great website, but should add dark mode"};output = [key:obj];   

Upvotes: 1

Related Questions