[IN DEV] Easy import of markdown docs to wiki

You’re absolutely right - it is possible to directly import into rich text. My fault for not checking that first - I had used the method suggested a while back for a different reason; I can’t recall if import to rich text was available at that time.
So yeah, if your source text is formatted as markdown correctly, then you should have no problems. Sorry for the confusion.

1 Like

Ah good, no worries! It’s a reasonable approach. I still strongly wish for at least single import (or copy/paste handling) for markdown into docs, and ideally bulk import of .md files to docs. It’s such a simple format and Fibery already mostly supports it. It could be a big help for people trying to migrate into Fibery from other tools = sales driver!

1 Like

I second this need. Migrating my team from Notion, we have a few hundred pages (FAQ, internal documentation, specifications …) which would be a pain to move to Fibery.

Only workaround I have for now is

  • export from notion as markdown + image (one zip file for a space or folder)
  • open folder in an IDE such as IntelliJ
  • open each page as markdown viewer
  • select all, copy
  • open proper page in fibery, paste (which thanksfully keeps most formatting and inserts images)

I’d really appreciate a way to automate this process.

2 Likes

I’ve started work on a script which would automate this migration from a notion export (basically any folder with markdown and picture files, similar to what you would share on github/gitlab …).

What works

  • updating a rich text field from a markdown file
curl -X POST https://colisweb.fibery.io/api/commands \
     -H 'Authorization: Token SECRET' \
     -H 'Content-Type: application/json' \
     -d \
      '[
         {
           "command": "fibery.entity/query",
           "args": {
             "query": {
               "q/from": "Produit/Solution",
               "q/select": [
                 "fibery/id",
                 "Produit/Name",
                 { "Produit/Description": [ "Collaboration~Documents/secret" ] }
               ],
               "q/where": ["=", ["Produit/Name"], "$name" ],
               "q/limit": 2
             },
              "params": {
              "$name": "Test End 2 End Suivi de colis"
            }
           }           
         }
      ]'

jq '.content =  $md' --arg md "$(< /tmp/md)"  --null-input > /tmp/json

# use fibery/id from previous command

curl -X PUT https://colisweb.fibery.io/api/documents/$fiberyId?format=md \
     -H 'Authorization: Token SECRET' \
     -H 'Content-Type: application/json' \
     -d "$(</tmp/json)"
  • uploading an image to fibery
curl -X POST https://colisweb.fibery.io/api/files \
     -H 'Authorization: Token SECRET' \
     -H 'content-type: multipart/form-data' \
     -F 'file=@/tmp/Untitled.png'

Where I need help

How can I use the uploaded png file in the markdown rich-text field ?
IE, how to I replace ![Untitled](/Untitled.png) in my original markdown file ?

1 Like

I found the answer by peeking at the network view when doing it by hand, it is simply
![Untitled](/api/files/ba511eea-f8bb-447e-9fda-b8c5fddfaa22)

(with “fibery/secret”: “ba511eea-f8bb-447e-9fda-b8c5fddfaa22” in the answer to the upload request)

3 Likes

I’ve made great progress on one area : I can now with this script (it’s scala but you should be able to port it easily to python or javascript) update all the entities with markdown + images, in a chosen field.

I’m now struggling with creating documents and folders from the API. I have not found documentation here and based on these posts I’m worried if this is possible.

Maybe @Oleg or @Chr1sG you could clarifiy the status about the API for managing documents and folders ?

2 Likes

Hi, @Michel_Daviot

Please find my js function to create/update docs

    const getDocumentsBatchCommand = (command) => async ({client, format, args}) => {
        logger.info(`[Fibery API]: Collab doc command: ${command} with ${args.length} ${format} docs`);
        return client.post(`api/documents/commands`, {
            searchParams: {
                ratelimit: 'on',
                format,
            },
            json: {
                command,
                args,
            },
            headers: await getAuth(),
        });
    };
    const updateDocuments = getDocumentsBatchCommand('create-or-update-documents');
    const appendDocuments = getDocumentsBatchCommand('create-or-append-documents');

where format is one of md, json, html or text

and args is array of elements which looks like

{
            secret: `XX-YY-ZZZ-it is just a doc secret`,
            content:`Hello`
 }
3 Likes

Please find below an example of creating folder

    const createFolder = async ({client, app, name, parent = null, publicId = null}) => {
        const operationId = uuid.v4();
        const folderId = uuid.v4();
        const result = await client.post(`api/views/json-rpc`, {
            json: {
                jsonrpc: `2.0`,
                method: `create-folders`,
                params: {
                    values: [
                        {
                            'fibery/Parent Folder': parent,
                            'fibery/id': folderId,
                            'fibery/name': name,
                            'fibery/container-app': {'fibery/id': app.id},
                            'fibery/public-id': publicId,
                        },
                    ],
                },
                id: operationId,
            },
            headers: await getAuth(),
        });
        if (result.error) {
            throw new Error(result.error.message);
        }
        return _.get(result, `result[0]`);
    };

In my code call looks like

const folder = await fibery.createFolder({
    app: app,
    name: folderName,
    parent: {'fibery/id': getFiberyId(step)},
});

3 Likes

I’ve added some documentation to the script. Also here is how I export from notion :
image

Thanks @Oleg I’ll try those to upload the rest of my data !

1 Like

@Michel_Daviot

Nice, I believe we will add support for integration apps in future to allow the import of documents and folders. It is partly implemented, but I am waiting for fibery core implementation of sub-documents.

1 Like

I guess I did not make my request clear enough, I want to create a document in a folder (or directly in a space), how can I specify the document name and location ?

Never mind, I manged to create a folder and I will be able to guess how to create a document by peeking at the developper tools while doing it from the front-end. It was a good idea to use the same API for front-end and automations :slight_smile:

I’ll finish this next week, thanks again for your help !

1 Like

I’ve updated the scala script, it is now also able to import all mardown files into fibery documents (inside folders).

As documented in the script, I was surprised that the secretId is generated on the client side (what would happen if a secret is reused ?).

Note for future users : it is not perfect, for instance links to notion pages are note translated to internal fibery links. But it saves some time when importing hundreds of documents with attached images !

1 Like

I guess you’ve seen this topic:

I reckon you could use the same logic to create working links within Fibery to replace the Notion links.

1 Like

I had not seen it, thanks ! We had not that many internal links to migrate so we updated them by hand, but the automation is a good reference.

Thanks Michel_Daviot, this script is really promising. For us to move to fibery a massive md import is needed, keeping the links between documents. This doesn’t seem to be easy (or supported by this script).

Is Fibery going in this direction with a native import? Many teams are stuck with data from other systems, might facilitate migration.

1 Like

@Jose_Quesada
What platform do you hope to import from?

1 Like

This is plain text files on my hard drive. Well, and images.

1 Like

How are they linked? Is it via some proprietary syntax?

1 Like

Using double bracket syntax [[title of the markdown file without the .md extension]]

2 Likes