identity: author: yourname name: flomo label: en_US: Flomo Note zh_Hans: Flomo 浮墨笔记 description: en_US: Add notes to your Flomo account directly from Dify. zh_Hans: 直接从 Dify 添加笔记到您的 Flomo 账户。 icon: icon.pngcredentials_for_provider: api_url: type: secret-input required: true label: en_US: API URL zh_Hans: API URL placeholder: en_US: https://flomoapp.com/iwh/{token}/{secret}/ help: en_US: Flomo API URL from your Flomo account settings. zh_Hans: 从您的 Flomo 账户设置中获取的 API URL。tools: - tools/flomo.yamlextra: python: source: provider/flomo.py
创建 tools/flomo.yaml:
identity: name: flomo author: yourname label: en_US: Save to Flomo zh_Hans: 保存到 Flomodescription: human: en_US: Save the conversation content as a Flomo note. zh_Hans: 将对话内容保存为 Flomo 笔记。 llm: > Saves content to the user's Flomo account. Use this tool when the user asks to save, capture, or remember the current message. Takes a single `content` parameter containing the text to save.parameters: - name: content type: string required: true label: en_US: Note content zh_Hans: 笔记内容 human_description: en_US: Content to save as a note in Flomo. zh_Hans: 要保存为 Flomo 笔记的内容。 llm_description: The text to save as a Flomo note. form: llmextra: python: source: tools/flomo.py
import requestsdef send_flomo_note(api_url: str, content: str) -> None: """ Send a note to Flomo via the API URL. Raises requests.RequestException on network errors, and ValueError on invalid status codes or input. """ api_url = api_url.strip() if not api_url: raise ValueError("API URL is required and cannot be empty.") if not api_url.startswith('https://flomoapp.com/iwh/'): raise ValueError( "API URL should be in the format: https://flomoapp.com/iwh/{token}/{secret}/" ) if not content: raise ValueError("Content cannot be empty.") headers = {'Content-Type': 'application/json'} response = requests.post(api_url, json={"content": content}, headers=headers, timeout=10) if response.status_code != 200: raise ValueError(f"API URL is not valid. Received status code: {response.status_code}")