Refile to roam from gtd inbox

I am currently setting up a GTD workflow and I want to use roam as my knowledge base.
The idea is to capture everything into my inbox and in case it should be kept for reference I want to refile it into roam.

From what I have seen most people capture directly into roam.
What would be the best practice to refile from a gtd inbox. Or is it strictly advised to separate TODO inbox from reference inbox?

I am trying to write a function to refile a tree from my regular inbox.org to my roam directory.
It should either refile the tree into an already existing file or create a new file from the tree.

I am a total noob with elisp. Started writing elisp yesterday. That’s how far I got so far:
Basically I copied most of the code from org-roam.el > org-roam-find-file ()

;; initial prompt should be the text of the tree
(defun stfl/refile-to-roam2 (&optional initial-prompt)
  (interactive)
  (let* ((completions (org-roam--get-title-path-completions))
         (title-with-tags (org-roam-completion--completing-read "File: " completions :initial-input initial-prompt))
         (res (cdr (assoc title-with-tags completions)))
         (file-path (plist-get res :path)))
    ;; if we have a file-path -> call org-refile
    (if file-path
      (let ((org-refile-targets ((file-path  :maxlevel . 4))))   ;; FIXME file-path seems to be the incorrect type
        (call-interactively 'org-refile))
      ;; if we can't find a file call a org-roam-capture
      ;; TODO this does not yet actually refile the subtree
      (let ((org-roam-capture--info `((title . ,title-with-tags)
                                      (slug  . ,(funcall org-roam-title-to-slug-function title-with-tags))))
            (org-roam-capture--context 'title))
        (setq org-roam-capture-additional-template-props (list :finalize 'find-file))
        (org-roam-capture--capture))
      )))

I ran this through the debugger and getting file-path works and is type string.
org-refile-targets requires some other type?
The problem is not actually related to roam but org-refile-targets and my elisp noob’ness but I hope someone can direct help me out…

1 Like

I wrote a function to refile existing headlines to new org-roam note files: Creating an org-roam note from an existing headline

1 Like

If you are refiling to a pre-existing org-roam file, the following might be helpful: