Replace names for numbers

Hi everyone,

I’m trying to write a rule in DSL that substitutes names for numbers in a string and then sends it to telegram,
but not having so much programming knowledge I stopped,
can someone help me?

Thank you

val String stringa = Thing_Generica_MQTT_mesh_topologia_mesh_topologia.state.toString

val replacements = newHashMap(
    2229517531 -> 'enel',
    2224630436 -> 'tenda',
    480779657 -> 'bridge',
    983542511 -> 'studio',
    2229517562 -> 'garage',
    756469405 -> 'presa2',
    2444924666 -> 'cucina',
    2391584726 -> 'cantina',
    3044785750 -> 'caldaia',
    985590499 -> 'presa1',
    3957342317 -> 'soggiorno',
    3892349880 -> 'bagno',
    2391605396 -> 'remota',
    2132239199 -> 'cameretta',
    2786662246 -> 'camera'
)

var String nuovaStringa = stringa

replacements.forEach [numero, nome |
    nuovaStringa = nuovaStringa.replace("\"nodeId\":$numero", "\"nodeId\":\"$nome\"")
]

logInfo("Nuova Stringa:", nuovaStringa)

val telegramAction = getActions("telegram", "telegram:telegramBot:123eee528ttt")
telegramAction.sendTelegram(nuovaStringa)