Logo

Dify Workflow DSL for Xiaohongshu Operations

avatar hugo 02 Dec 2024

The previous article titled “Building a Comprehensive Xiaohongshu Operation Workflow Based on Dify and Large Language Models” received considerable attention, and I would like to share the workflow DSL mentioned in that article, along with some usage notes.

First, many readers may not be familiar with Dify’s workflow, so I will quote the official description from Dify:

The workflow reduces system complexity by breaking down complex tasks into smaller steps (nodes), decreasing reliance on prompt engineering and model inference capabilities, improving the performance of LLM applications for complex tasks, and enhancing the system’s interpretability, stability, and fault tolerance.

Dify workflows are divided into two types:

Chatflow: Designed for conversational scenarios, including customer service, semantic search, and other dialog-based applications that require multi-step logic in response construction.

Workflow: Aimed at automation and batch processing scenarios, suitable for high-quality translation, data analysis, content generation, email automation, and more.

Source: https://docs.dify.ai/v/zh-hans/guides/workflow

The workflow type used in “Building a Comprehensive Xiaohongshu Operation Workflow Based on Dify and Large Language Models” is the Workflow type.

Preparation Steps

  1. Register for an account at https://dify.ai/.
  2. Sign up at https://openai.com/ and obtain an OpenAI API key.
  3. Register for an account at https://www.imgrender.net/ and get an API key.

Registering for an account at https://dify.ai/ is quite straightforward, so I won’t elaborate further.

Due to OpenAI’s restrictions in mainland China and Hong Kong, obtaining an OpenAI API key in China is not an easy task. Users can select large language models provided by domestic companies such as Tongyi Qianwen, Wenxin Yiyan, and Moonshot AI in the Dify model provider settings.

Refer to the respective large language model websites for instructions on obtaining the corresponding API key, and then return to the Dify model provider settings to fill in the API key. Subsequently, you can replace the ChatGPT model in the LLM nodes of the workflow.

Dify Model Provider.png

Taking Moonshot AI as an example, after clicking the settings button, you can reach the Moonshot AI website through the guided instructions, register an account, and create your own API key to fill in the Dify settings page.

moonshot-ai-key.png

Register for an account at https://www.imgrender.net/, navigate to the console, and after creating an application, you will receive an API key. Each account has a monthly quota of 1000 free requests.

img-render-api-key.png

How to Use the Comprehensive Xiaohongshu Operation Workflow

On the page https://cloud.dify.ai/apps, click on “Import DSL File”, select URL, and enter https://raw.githubusercontent.com/beansmile/dify-workflow/main/DSL/小红书运营一条龙.yml.

Import DSL File.png

After successful import, if you do not have an OpenAI API key, you can follow the instructions above to add a new model and select your own new model for all LLM nodes. For example, the Dark Side of the Moon shown in the screenshot.

moonshot-ai.png

Then find the ImgRender node, click on “Authenticate API-Key”, and replace the input box with your own ImgRender API key.

iShot_2024-09-02_18.13.21.png

iShot_2024-09-02_18.13.30.png

After saving, you can click the “Run” button in the upper right corner to test. If the test is successful, you can publish it for public users to use.