How to add a custom URL fragment to a flow

Hi there,
I鈥檇 like to modify, or create, a flow based on the Nextcloud Talk flow to write into a conversation: spreed/RegisterOperationsListener.php at master 路 nextcloud/spreed 路 GitHub

I鈥檇 like to adjust the URL created to include additional elements, for example, instead of cloud.domain.tld/s/3dhjfdkhhke it should be cloud.domain.tld/apps/memories/s/3dhjfdkhhke

Is this possible?

Cheers

I鈥檓 not entirely clear on what you鈥檙e trying to do, but I assume you鈥檝e already seen the various dev related docs - e.g.

https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/flow.html?highlight=talk

https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/talk.html?highlight=talk

https://docs.nextcloud.com/server/latest/developer_manual/search.html?q=Talk&check_keywords=yes&area=default

Yes is possible, Peace of Cake:

This is the absolute basic script as example, you can make it more complex if you want.

Create this script, e.g. in /usr/local/bin/link2memories.sh:

#!/bin/bash
# Adapt this to your URL:
HOST="https://yourcloud.tld"

    while (( "$#" )); do
        case "$1" in
        --help)
            echo "/link2memories - A Nextcloud Talk chat wrapper to create"
            echo "$HOST/apps/memories/s/<token> out of"
            echo "$HOST/s/<token>"
            echo
            echo "Usage: /link2memories \$URL"
            exit 0
            ;;
        *)
            break
            ;;
        esac
    done

echo "$1" | sed "s|$HOST/s/|$HOST/apps/memories/s/|1"

make it executable:

chmod +x /usr/local/bin/link2memories.sh

Now add the command to the Talk-Commands like described here:

occ talk:command:add link2memories link2memories "/usr/local/bin/link2memoriessh {ARGUMENTS}" 2 2

Now everybody who enters

/link2memories https://cloud.domain.tld/s/3dhjfdkhhke

gets

https://cloud.domain.tld/apps/memories/s/3dhjfdkhhke

in a clickable form back in the chat.

If you want a shorter comand (e.g. l2m) you know how to change this :wink:

1 Like

Woa thanks, that is pointing in the right direction :slight_smile:

Would it be possible to use this as part of a flow, to automate creating such 鈥渆nhanced鈥 links whenever a flow posts a new upload to the room?

Or would every user need to use the bot command and paste the newly provided link by the talk bout and 鈥渢ranslate鈥 it to the desired form?

1 Like

Basically anything is possible, of course, it just depends on how much time and brainpower you want to invest.

I would first rewrite/rename this solution so that everyone in the room can understand and apply it.