Can't figure out how to separate text sections with parser

Hi guys! I’m trying to build an automated cold outreach system where perplexity or chatgpt (I currently am paying for perplexity tho) analyzes prospects from my google sheet and generates a personalized cold outreach e-mail. I ran into a problem when trying to parse the results from perplexity so that the subject line of the email and body are separated out. Then I can map them in in the email module to create an e-mail correctly. I tried both the JSON and text parser (match pattern) modules and keep getting an empty output. For JSON its even worse, because I get an error " Validation failed for 1 parameter(s). Missing value of required parameter ‘json’."

I tried to tell perplexity to format the email in a format that would be readable by the parsers (first the text parser and then I tried the json format). Does anyone have a suggestion how to do it properly? Also should I use a “watch new rows” module for google sheets instead, so that it only triggers when new information is added to the sheet?

I appreciate any help.

Hello! Welcome to the Make Community!

Can you please show an example output of the Perplexity Module, as well as the configuration of your parse JSON?

Benjamin

1 Like

Hi @Esma

  • provide the output bundles from each module (Google sheet and Perplexity module).
  • also make sure the cell that has data is correctly mapped to Perplexity module.

provide scenario (also both input and output bundles) for more clarification to the query.

Hi! Here are the screenshots:





Hi! I added some screenshots above and here are some more from Sheets and iterator:


Hello @Esma,

Thank you for all these details!
Apparently, the Body field Perplexity generates contains “carriage returns / line feeds”, which breaks the Parse Json.
You don’t need to create any Data Structure for the JSON Parser.

One weird idea I have. I will let @Anshul_Soni tell us if he finds a better one, is to ask Perplexity to replace any “new line” with a few special characters (for example replace it with || )
Like this body will not contain any new line, and your ParseJSON will work properly.

Another idea is to remove and replace any carriage return in the mapping for JSON. See an example below:

And then, when you map “Body” from Parse JSON in you email Body, you do the exact opposite action:

I hope it can solve your issue

Benjamin

Hi! Thank you so much for the feedback! I tried it and unfortunately I got the same error. Only when I removed any formatting, and used your string for the parser, did I get the result from the screenshot, but again with an error that source is not a valid JSON:

I had to upload to imgur because suddenly my browser does not respond the clicking attach buttons anywhere. It only works for websites where I can directly drop the photos into the upload box…

1 Like

Hello.

I can see that I gave you a wrong workaround because when doing so, it also replaced the new lines between subject and body… which breaks the original JSON…

Can you try and ask perplexity to « replace any new line in body by || »
Or another:
« Escape any new line character »

The goal is to obtain a JSON with subject and body, but with Body having no new line.

If it still doesn’t work, can you download the output of Perplexity and send it here so that I can test on my side?

Benjamin

1 Like

Hi! Perplexity sometimes ignores my request to not add intros, outros and recaps, only the pure e-mail template and it breaks the JSON again. It also keeps doubling up the || characters, which is quite weird. I’m using a small model adapted for online searching, maybe I should use a bigger one and that could change the results? Anyways, here is the entire blueprint and you can check what’s going on. I’ve only connected the first 4 modules until I can get the correct output.

blueprint.json (155.0 KB)

1 Like

Hello @Esma,

Thanks for all the information you provided.

I tested with ChatGPT, and it worked

And this is how I configured the completion


As you can see, I used the System role to tell it to generate a JSON with the fields I want. The last “JSON Object” field is not really used, most important is to tell System what to do

I used the Assistant role to tell it it’s good at Cold Outreach, I don’t know if it changes anything :grin:

And I typed my User prompt. I removed the last part where I ask for a subject and body, since I already mentioned it in the System role.

The interesting part is that ChatGPT automatically escaped new lines with a \n, which is perfect because it can be used as-is and doesn’t break the Body.


So since Perplexity seems to forget to do it, you can explicitly ask him.

Can you then try to:

  • add a System role and ask: generate a JSON file with a “subject” and “body” fields. In the body field, escape all special characters, for instance replace newlines with \n
  • add Assistant role: you are expert in cold outreach
  • add you user role. You can also add the same info about escaping special characters. But you should try without first.

Let me know the outcome.

Benjamin

2 Likes

Oh darn! I forgot to set the system message! Ok now I see the same output coming out of perplexity but still an error with the JSON parser. I think I didn’t set up the parser correctly. Here are my screenshots now:



You don’t need to add any data structure, it will parse automatically if the json is correct.
From the picture, it seems ok, but you don’t need to replace the || because we no longer ask it to replace with these characters.

It’s like now it just removed any new line, it’s weird.

1 Like

I managed to get the exact same output format as you and I removed the JSON string that was trying to replace the special characters. It is still not working properly. I’m so sorry for taking so much of your time! I took screenshots again to show you. Also, if it keeps not working, I guess I’ll just do a bit of a “dirty” workaround by putting 2 perplexity modules one after the other, asking the second one to create a compelling title for the first auto-generated text. Then I can map each of the message.content fuctions to the desired spaces in the e-mail module.



Hello!

Don’t worry! I just hope we’ll manage to make it work. The first screenshot with the text seems good; is it from a latest call you did? If you get this output, the Parser should work.

The second one has an issue, because we can see that it added three quotes (´´´) at the beginning and end of the content field?!? Which breaks the Parse JSON.

If it always generates these characters, we could add a replace function to change these 3 quotes to EmptyString. In that case it will work.
But if it keeps changing (and add some other characters), it’s a bit more complex…

So, you can try this

But again, if sometimes it adds another type of characters, it will stop working. This workaround only works if Perplexity keeps returning these 3 quotes at the beginning and end of the “content”.

One other way is to only keep what’s inside { and } using a regular expression, but it requires one other module, which would not be perfect since, in that case, you could also do the workaround you mentioned (having 2 Perplexity calls)…

And again, the content from the first screenshot you just sent is correct; so if you managed to get a prompt that generates this, you should be able to Parse the Json.

Benjamin

Hi! I figured out that with instruct models, they do not add any additional characters, but JSON parser still doesn’t work. It worked for you with ChatGPT, and I am now wondering if it just doesn’t work with the perplexity module? If you want, I can send you the updated bundle and create a temporary perplexity API key just for you to be able to use the same exact module and see what kind of output you get.

Hello @Esma,

yes you can send me the key in a DM, so that I test on my side.

Benjamin

Thank you so much! How do I DM you? I checked your profile and saw no such option

Hi @Esma , here’s a guide on sending DMs in the community: 📚 Mastering the Make Community: Send Direct Messages

2 Likes