Hi, I’m a software dev and new to Logseq but I find it very fascinating to write my daily journals and I want to integrate it into my daily workflow. I have used syncthing to setup sync between my linux laptop and android phone and eventually plan to move onto a flow like the one described here => My multi-devices Logseq sync setup | akhy.Write(blog).
In the above blog, the author uses a spare droplet instance (remote server) to host his logseq notes and uses syncthing to sync across all devices and his server.
Now what I want to do is something similar but I want to be able to interact with the version on server with an api. I know that Logseq does provide an api to interact with it but that api requires the gui version of Logseq to keep running. What I want to do is to run Logseq in a headless mode on the server.
I want to be able to inscribe my voice notes on the daily journal. For that I am planning to make a simple android app that records my voice notes and then transcribes them via a third party api like whisper or something else and then I want to insert those notes in the logseq daily journal. Can somebody offer some solutions for this dilemma? I know the DB version is on the way and would probably solve this issue of mine too but in the meantime what d you recommend I do?
I believe the best way to achieve these results is to create a Telegram chatbot with a script that uses OpenAI to convert your audio recordings into notes and subsequently send these notes to Logseq through an API that you can build and host on your server. This API will receive the text and write the content into Logseq text files.
Since Logseq keeps all data in text files, creating, editing, and adding data is not a complex task. Although I’m not aware of an official API for this purpose, the CLI project “logseq-query” might help in identifying the correct file to be edited.
Therefore, I see the complete solution as comprising three parts: (a) synchronization, (b) a custom backend API, and (c) a Telegram chatbot integrated with OpenAI.
For part (a) synchronization, you have already used Syncthing. Personally, I solved this problem with a script that automatically performs commit, push, and pull on a private Git server (I use the free version of Bitbucket). On Android, I sync folders between Android and my Linux server, and the script on the server handles commit, push, and pull. The advantage of this approach is that I keep my notes secure and with a history in Git.
To implement part (b), the custom API, you can create the backend using any language of your choice, such as Python, where an endpoint would be capable of receiving your calls on the server and writing the content into Logseq text files.
For implementing part (c), the chatbot, there are various tutorials available.
Thanks a lot @educostadev for your answer. I just had a few questions if you don’t mind. Does manually editing/creating a file effect the working of logseq in any way? I had the preconception that logseq maintains a graph file or something similar for every entry we make though I might be wrong. Please enlighten me on this.
You’re right! You’ll have to re-index the graph on ALL clients once all the files are synced and is not possible do it via CLI. I don’t know where the re-indexed file is stored nor why the same re-indexed files does not work across multiple devices.
Do you think these issues will be resolved in the new db version?
I am looking at a similar problem.
https://docs.logseq.com/#/page/local%20http%20server exposes the plugin API over JSON on localhost (Setting is Settings > Features > HTTP APIs server
now) but I am also thinking how I might run logseq without a UI, set up sync, and use that to integrate some services…
nbb-logseq/examples/fly-io at main · logseq/nbb-logseq · GitHub is an example of a node.js service using nbb-logseq to interface with the graph…
I’ve been thinking about this for a while, as well. While I’m interested in an iOS solution, this is important to me.
One idea I’ve considered is making an API that would power custom, authenticated OpenAI GPT Action that would enable creating a file that would get added to the graph. The ChatGPT apps already support whisper, so it wouldn’t be necessary to implement that part. Of course, I think this would depend upon the “plus” or one of the enterprise versions of ChatGPT.
I’ve also been looking at the HTTP APIs, but I haven’t seen so many examples of how to use them. From what I can tell, the plugin API docs are for a typescript plugin API, not an HTTP API, and the interfaces don’t quite make sense in an HTTP context without some translation.
nbb-logseq
does seem like something that could enable this, but, I must admit, as someone who doesn’t write a lot of clojurescript, it seems like it would be a lot easier to just create files and rely on syncing.
One solution which hasn’t been proposed here yet would be to rely on “eventual consistency.” One could add voice messages to a queue, transcribe them and put them in another queue, then check the queue via a plugin that’s open in Logseq. But that wouldn’t work to insert them on mobile; it would only insert them the next time you opened the GUI version of Logseq on a desktop.