Building a Blog SEO Analysis Tool Based on Dify Workflow
Introduction
Importance of SEO
Search Engine Optimization (SEO) is a key strategy for improving a website’s ranking on Search Engine Results Pages (SERP). By optimizing content and technical details, SEO can significantly enhance a website’s visibility and traffic, attracting more readers and potential customers. For blogs, good SEO practices not only increase readership but also enhance brand awareness and influence.
Overview of Dify Workflow
Dify Workflow is a core feature of the Dify platform that allows users to create and manage automated workflows through a visual interface. Users can integrate multiple tasks and tools into a single workflow, automating complex business operations.
Using Dify Workflow for SEO Analysis
In this example, the main focus is on automating tasks such as keyword research, content analysis, and link analysis through the Workflow, saving time and effort.
Building the Dify Workflow
(1) Create a Dify Workflow Application
(2) Construct the Workflow
This application mainly consists of three nodes:
Start: Accepts input parameters title, content
SEO LLM: Uses a large model to analyze the input parameters (gpt-3.5-turbo) and outputs relevant data based on the prompt
Output Data: Returns the output data from the large model
(3) After configuration is complete, publish directly
At this point, our flow can be executed directly in Dify.
However, to integrate it into the Beansmile blog system, we need to utilize another capability provided by Dify, which is the API access capability.
(4) Generate Basic Orchestration Chatbot API Key
At this point, the preparation work for the Dify flow is complete. In this section, we only need to save two things: API Key and API Server Address.
Integration into the Beansmile Blog System
Based on the construction of the above workflow, Dify provides an interface for our system to access. At this point, we only need to integrate the Dify interface.
(1) Integrate Dify Interface Code
So I found the internal AI tool of the company to help me automatically write the code, placed in the rails
lib below.
require 'httparty'
require 'singleton'
module Dify
class BaseClient
include HTTParty
include Singleton
base_uri 'https://api.dify.ai/v1'
def initialize
self.class.headers 'Authorization' => "Bearer #{api_key}"
self.class.headers 'Content-Type' => 'application/json'
end
def run_workflow(inputs: {}, response_mode: 'blocking', user: nil)
body = {
inputs: inputs,
response_mode: response_mode,
user: user
}.compact
response = self.class.post('/workflows/run', body: body.to_json)
if response.success?
response.parsed_response
else
Rails.logger.error("Dify API request failed: #{response.code} - #{response.body}")
raise "API request failed: #{response.code} - #{response.message}"
end
end
private
def api_key
raise NotImplementedError, "#{self.class} should implement api_key method"
end
end
class Seo < BaseClient
private
def api_key
Rails.application.credentials.dig(Rails.env.to_sym, :dify, :seo_api_secret)
end
end
end
The pseudo code for the call would be:
response = Dify::Seo.instance.run_workflow(inputs: {
title: params[:title],
content: params[:content],
}, user: current_user.id)
This achieves the integration with the Dify interface. By configuring the generated code into the blog system, after writing the blog, we can apply the SEO information generated by Dify.
(2) Final Effect in the Blog System
The above is the process and method of integrating Dify Workflow for SEO analysis in the Beansmile blog system. Through Dify Workflow, we can automatically extract key information from blog content and generate SEO-related information, facilitating the optimization of our blog.
Conclusion
This article introduced how to use Dify Workflow for SEO analysis, demonstrating the entire process from creating a workflow application to integrating it into the Beansmile blog system through specific steps. With Dify Workflow, we can automatically extract key information from blog content and automatically generate SEO-related information such as titles, descriptions, and URL slugs, enabling more effective SEO optimization for the blog.
As a middleware tool platform, Dify allows users to easily create and manage LLM (Large Language Model) applications through a visual interface. This enables users without programming experience to quickly build their own assistant applications, enhancing work efficiency. For example, through Dify, marketers can easily create SEO analysis assistants without relying on the technical team. For users with programming experience, Dify provides rich API interfaces, allowing them to create more customized and loosely coupled LLM capabilities to achieve more complex automation tasks.