Make SDK - escape double brace {{}}

How is the best approach to escape double brace , specially for defining a default in a parameter of Make SDK (integromat.com)?


I have an RPC that returns two read-only ("disabled": true) fields with a content and example and they use the same double brace that Make uses.

So, I need to understand if there is a way to show the double brace as it is, not interpreted like an parameter in Make Scenario.

RPC

Reference: Dynamic Fields RPC - Make Apps (integromat.com)

rpc://templatesGetExpectById

{
    "url": "/v1/templates/{{parameters.templateId}}",
    "method": "GET",
    "qs": {
        "organizationId": "{{parameters.organizationId}}"
    },
    "response": {
        "output": [
            {
                "name": "templateId_{{body.id}}_content",
                "label": "Content",
                "type": "text",
                "disabled": true,
                //"default": "{{ body.content }}"
                "default": "{{ decodeURL( replace( replace( body.content, '{{', '%7B%7B%7B' ), '}}', '%7D%7D%7D' ) ) }}"
                //"default": "{{ replace( replace( body.content, '{{', '`{{' ), '}}', '}}`' ) }}"
                //"default": "{{ replace( replace( body.content, '{{', '{' ), '}}', '}' ) }}"
                //"default": "{{ 'Hi {{name}}, this is an example of string with parameter with double brace.' }}"
            },
            {
                "name": "templateId_{{body.id}}_example",
                "label": "Example",
                "type": "text",
                "disabled": true,
                "default": "{{body.example}}"
            }
        ]
        /** Example Response
        {
            "channelId": "YUJQXx0GQeKDWd1N",
            "label": "Request Message",
            "category": "SUPPORT",
            "content": "Hello, {{1}}. Can we talk about your request {{requestid}} ?",
            "example": "Hello, John. Can we talk about your request #9981 ?",
            "status": "APPROVED",
            "approvedAtUTC": "2022-10-05T20:10:23.498Z",
            "id": "Yz2io0ke7ZKAhicn",
            "createdAtUTC": "2022-10-05T15:28:35.882Z"
        }
        */
    }
}

Parameters (Usage of the RPC)

Reference: Parameters - Make Apps (integromat.com)
Example of usage of the parameter (expect.imljson)

[
    {
        "name": "chatId",
        "type": "text",
        "label": "Chat ID"
    },
    {
        "name": "organizationId",
        "type": "select",
        "label": "Organization ID",
        "required": true,
        "options": {
            "store": "rpc://membersMeOrganizations",
            "nested": [
                {
                    // Template by Organization
                    "name": "templateId",
                    "type": "select",
                    "label": "Template",
                    "options": {
                        "store": "rpc://templates",
                        "nested": "rpc://templatesGetExpectById"
                    }
                }
            ]
        },
        "mode": "edit"
    },
    {
        "name": "params",
        "type": "array",
        "spec": {
            "type": "text"
        },
        "label": "Params"
    }
]

Example in a Scenario

So, the result is like the print below, but I need to show the RAW value, not interpreted like name is a parameter from Make.

I tried a few options, but none worked:

"default": "{{ replace( replace( body.content, '{{', '`{{' ), '}}', '}}`' ) }}"
"default": "{{ replace( replace( body.content, '{{', '{' ), '}}', '}' ) }}"

Also tried the approach @Krzysztof_Rupinski suggest, imagining it was the solution. But the result keeps the same, unfortunately.

"default": "{{ decodeURL( replace( replace( body.content, '{{', '%7B%7B' ), '}}', '%7D%7D' ) ) }}"

The best so far it was the option below:

"default": "{{ decodeURL( replace( replace( body.content, '{{', '%7B%7B%7B' ), '}}', '%7D%7D%7D' ) ) }}"

Hi @AndyDaSilva52,

you need to use the number of the module you are referring to as well

{{2.name}} could work depending on the output of the module you are trying to reference. Any chance you can show that output? :slight_smile:

The other day I was really struggling to escape semicolon, and I’ve found a rather hacky way, but it works :wink:

image
image

2 Likes

@Krzysztof_Rupinski This is exactly what I need. Thank you.

1 Like

Sorry, but your question will not make any difference for my situation

I’m not typing the content, If so, your point of view could make sense, because for the scenario in Make this is the right way.

If you notice I am talking about the Make SDK where I’m creating an app.

In this I create a parameter that will be filled through an RPC.

The API called from RPC return the content with double brace and there are nothing related to Make approach with double brace, it’s just the interpretation from then for parameters that for coincidence is the same from Make.

This parameter created dynamically also is disabled as I already showed.

Hi @AndyDaSilva52,

I need to apologise! I think I read it wrong, sorry! :confused:

Glad @Krzysztof_Rupinski was able to show s possible solution! :slight_smile:

1 Like

Hi @Krzysztof_Rupinski

I assumed your approach worked before correctly testing. Unfortunately, it didn’t.

I changed the original text I publish here in my question to make clear what I am trying to accomplish with examples and reference to the documentation.

Hope someone could help.

For now, I will try something temporary like:

"default": "{{ decodeURL( replace( replace( body.content, '{{', '%7B %7B' ), '}}', '%7D %7D' ) ) }}"

image

Hi @AndyDaSilva52,

As I was terribly wrong the first time I looked at it again(sorry again! I am ashamed looking at my first answer! :/).

I am not entirely sure if it helps you, but maybe it does.

So I was thinking about using a function to change the {{value}} you receive from that API. It’s still not perfect as it is not displayed as {{value}} but both solutions should lead to no manual change in the default-text so that the result is {{value}}.

function escapeBraces(apiValue) {
    let stringVariable = apiValue;
    //dummystring
    stringVariable = "{{braces}}"
    stringVariable2 = "{{braces}}"

    //option1
    stringVariable = stringVariable.replace("{{", "{.{")
    stringVariable = stringVariable.replace("}}", "}.}")
    debug(stringVariable);
    let result = "{{replace('" + stringVariable+"';'.';emptystring)}}"



    //option2
    stringVariable2 = stringVariable2.replace("{{", "{")
    stringVariable2 = stringVariable2.replace("}}", "}")
    debug(stringVariable);
    let result2 = "{{'{'emptystring'"+stringVariable2+"'emptystring'}'}}"

    return result2;
}

RPC Code (Dummy)

{
    "url": "https://jsonplaceholder.typicode.com/todos",
    "method": "GET",
    "response": {
        "output": [
            {
                "name": "test",
                "label": "Content",
                "type": "text",
                "default": "{{escapeBraces(apiValue)}}"
            }
        ]
    }
}

Screenshots of the results


Hope it helps! :slight_smile:

1 Like

@Richard_Johannes

I sincerely appreciate your effort.

Considering what you concluded, I will stay with the simplification:

"default": "{{ decodeURL( replace( replace( body.content, '{{', '%7B %7B' ), '}}', '%7D %7D' ) ) }}"

For me, this is the best so far I could do without the need of an IML Function:

image

Thanks.

2 Likes