DEV Community

Elowen
Elowen

Posted on

Parse People Also Ask Results in a Dify Workflow

People Also Ask data is useful for content research, but raw questions are not ready to use by default.

If you pass the entire SERP response into a Dify LLM node, the prompt gets noisy fast. A better workflow is to call a SERP API, extract only the people_also_ask field, clean it, deduplicate it, and pass a compact question list into the next node.

This walkthrough shows a simple Dify workflow pattern using TalorData SERP API as the search data source.

Workflow shape

The workflow has four steps:

  1. Start node: accepts a keyword or topic.
  2. HTTP Request node: calls the SERP API.
  3. Code node: extracts and deduplicates People Also Ask questions.
  4. LLM node: groups the questions into content angles or brief inputs.

The important part is the middle layer. Do not make the LLM parse a full SERP response if you only need questions.

Step 1: Create the input

Create a workflow input variable:

query
Enter fullscreen mode Exit fullscreen mode

Example input:

serp api pricing
Enter fullscreen mode Exit fullscreen mode

Keep the first version to one query. Multi-query workflows are easier after the response shape is stable.

Step 2: Add the HTTP Request node

Use a POST request.

URL:

https://serpapi.talordata.net/serp/v1/request
Enter fullscreen mode Exit fullscreen mode

Headers:

Authorization: Bearer <TALORDATA_TOKEN>
Content-Type: application/x-www-form-urlencoded
Enter fullscreen mode Exit fullscreen mode

Body parameters:

engine=google
q={{ query }}
json=2
Enter fullscreen mode Exit fullscreen mode

If your Dify workspace uses a different variable reference format, adapt the q value to the variable syntax shown in your workflow editor.

Step 3: Inspect the field you need

The field to inspect is:

people_also_ask
Enter fullscreen mode Exit fullscreen mode

For this workflow, the rest of the SERP response is secondary. You may keep organic results for later context, but the first parser should focus on questions.

A clean intermediate result can look like this:

[
  { "question": "What is a SERP API?" },
  { "question": "How do I use Google Search data in an AI workflow?" }
]
Enter fullscreen mode Exit fullscreen mode

Step 4: Deduplicate questions

People Also Ask questions can be repetitive. Some differ only by casing, punctuation, or small wording changes.

In a Code node, normalize the question before deduplication:

const paa = $json.people_also_ask || [];
const seen = new Set();
const questions = [];

for (const item of paa) {
  const raw = item.question || item.title || "";
  const question = raw.trim();

  if (!question) continue;

  const key = question
    .toLowerCase()
    .replace(/[?!.]/g, "")
    .replace(/\s+/g, " ");

  if (seen.has(key)) continue;

  seen.add(key);
  questions.push({ question });
}

return [
  {
    json: {
      query: $json.request_params?.q,
      questions,
      question_count: questions.length,
    },
  },
];
Enter fullscreen mode Exit fullscreen mode

This gives the LLM a compact list instead of a full API response.

Step 5: Ask the LLM to group, not invent

The next LLM node should transform the extracted questions. It should not invent a new list from scratch.

A prompt can be simple:

You are helping create a content brief from real People Also Ask questions.

Input:
{{ questions }}

Group these questions into 3-5 search-intent clusters. Keep the original questions visible under each cluster. Do not add questions that are not present in the input.
Enter fullscreen mode Exit fullscreen mode

This keeps the workflow grounded in the PAA data.

Step 6: Return a useful output

A practical output format:

Topic: SERP API pricing

Cluster 1: API basics
- What is a SERP API?
- How does a SERP API work?

Cluster 2: Use cases
- How do AI agents use search data?
- How can SEO teams automate SERP monitoring?

Cluster 3: Evaluation
- What should I compare when choosing a SERP API?
Enter fullscreen mode Exit fullscreen mode

That output is easier to turn into a brief than a raw list of questions.

What to log

During testing, log:

  • input query
  • response timestamp if available
  • number of PAA items returned
  • number of deduplicated questions
  • final grouped clusters

If a brief looks weak, you can inspect whether the issue came from the query, the SERP response, the parser, or the LLM grouping step.

Final thought

A Dify workflow does not need to hand the entire SERP response to an LLM. For content research, it is often better to extract one useful field, shape it carefully, and then let the LLM organize it.

If you want to test this with live search data, new TalorData accounts include 500 responses for a small Dify PAA workflow.

Top comments (0)