Swirls

SWIRLS_

  • How it works
  • Pricing

56 matches

OverviewDeliver client operations10Win and grow accounts8Resolve customer issues6Create and distribute content9Run people and operations5Review money and agreements3Monitor systems and data9Compose dependable work6

56 matches

OverviewDeliver client operations10Win and grow accounts8Resolve customer issues6Create and distribute content9Run people and operations5Review money and agreements3Monitor systems and data9Compose dependable work6
← Customer SupportWebhookView on GitHub

Review Sentiment Analysis

Analyzes product review sentiment and persists results for dashboards.

ai

Source

/**
 * Analyzes product review sentiment and persists results for dashboards.
 */

webhook product_review {
  label: "Product Review"
  schema: @json {
    {
      "type": "object",
      "required": ["product_id", "review_text", "rating"],
      "properties": {
        "product_id": { "type": "string" },
        "review_text": { "type": "string" },
        "rating": { "type": "number", "minimum": 1, "maximum": 5 },
        "reviewer_name": { "type": "string" }
      }
    }
  }
}

workflow analyze_review {
  label: "Analyze Review Sentiment"

  root {
    type: code
    label: "Extract review"
    code: @ts { return context.nodes.root.input }
    outputSchema: @json {
      {
        "type": "object",
        "properties": {
          "product_id": { "type": "string" },
          "review_text": { "type": "string" },
          "rating": { "type": "number" },
          "reviewer_name": { "type": "string" }
        }
      }
    }
  }

  node analyze {
    type: ai
    label: "Analyze sentiment"
    kind: object
    model: "google/gemini-2.5-flash"
    prompt: @ts {
      const review = context.nodes.root.output
      return "Analyze the sentiment of this product review.\n\nRating: " + review.rating + "/5\nReview: " + review.review_text
    }
    schema: @json {
      {
        "type": "object",
        "required": ["sentiment", "score", "themes"],
        "properties": {
          "sentiment": { "type": "string", "enum": ["positive", "neutral", "negative", "mixed"] },
          "score": { "type": "number", "minimum": -1, "maximum": 1 },
          "themes": { "type": "array", "items": { "type": "string" } },
          "actionable_feedback": { "type": "string" }
        }
      }
    }
  }

  node result {
    type: code
    label: "Combine results"
    code: @ts {
      const review = context.nodes.root.output
      const analysis = context.nodes.analyze.output
      return {
        product_id: review.product_id,
        rating: review.rating,
        sentiment: analysis.sentiment,
        score: analysis.score,
        themes: analysis.themes,
        actionable_feedback: analysis.actionable_feedback || ""
      }
    }
  }

  flow {
    root -> analyze
    analyze -> result
  }
}

stream review_sentiments {
  label: "Review sentiments"
  workflow: analyze_review
  version: v1

  versions: {
    v1 {
      schema: @json {
        {
          "type": "object",
          "required": ["product_id", "rating", "sentiment", "score"],
          "properties": {
            "product_id": { "type": "string" },
            "rating": { "type": "number" },
            "sentiment": { "type": "string" },
            "score": { "type": "number" },
            "themes": { "type": "array", "items": { "type": "string" } },
            "actionable_feedback": { "type": "string" }
          }
        }
      }

      condition: @ts { return context.output.result != null }

      prepare: @ts { return context.output.result }
    }
  }
}

trigger on_review {
  webhook:product_review -> analyze_review
  enabled: true
}

Flow

Trigger to workflow

product_reviewwebhook
analyze_review
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

Workflow nodes

CODE
Code Node
Extract review
AI
AI Node
Analyze sentiment
CODE
Code Node
Combine results
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.