https://discord.gg/botpress logo
#🤝help
How do I code a textlink for a variable?
# 🤝help
b

bumpy-morning-51656

07/24/2023, 11:31 PM
Here is my code, I want "workflow.nextMsg3" to output a text link in the next message, but the message keeps saying error, and i'm convinced something is wrong with my code.
Copy code
if (workflow.whatIssue === 'Dryness (Chap lips, Dry skin)') {

  workflow.nextMsg2 += '\n For dry skin anywhere on your body, I recommend the "Fix Your Sh*t" Healing Balm. It\'s jam packed with plant based and natural ingredients to soothe your dry skin fast, and comes in various sizes.'
  workflow.nextMsg3 += (Click Here - Fix Your Sh*t)[https://gingerganics.com/products/fix-your-sht-healing-balm?variant=43060603617509&selling_plan=3903226085]

}
q

quiet-hairdresser-14769

07/25/2023, 12:11 AM
Is that your full code or do you catch the error somewhere? If not, add this after the if statement catch (error) { console.error('Error:', error.message); } Then run it again until the error occurs, then check what error it caught in the console. If it caught an error message, please paste it so we can see where your error is coming from precisely.
b

bumpy-morning-51656

07/25/2023, 12:30 AM

https://cdn.discordapp.com/attachments/1133179601636560998/1133194460528914432/image.png

https://cdn.discordapp.com/attachments/1133179601636560998/1133194810044469298/image.png

q

quiet-hairdresser-14769

07/25/2023, 12:35 AM
just add your asterisk back in
seems to work, lol. I didn't know you can do links like this. I learned something as well
My previous method was to literally write a js script that runs inside an HTML file that redirects the browser window to a site, and then to upload the file and have the bot present the user with the link to the file. When they click it, it opens the html, runs the script and then shows the new website, but this is so much simpler
b

bumpy-morning-51656

07/25/2023, 12:40 AM
It still doesnt work for me lol, it works when I put it into a normal text but I need it in the variable text
q

quiet-hairdresser-14769

07/25/2023, 12:40 AM
Ok... give me a sec
b

bumpy-morning-51656

07/25/2023, 12:41 AM
Heres the screenshot of the whole block

https://cdn.discordapp.com/attachments/1133179601636560998/1133197185954095227/image.png

i removed the https part to see if that would do something but it didnt do nothing
q

quiet-hairdresser-14769

07/25/2023, 12:42 AM
nah that's not the issue
I think it might be that the link needs to be in quotation marks
b

bumpy-morning-51656

07/25/2023, 12:42 AM
Let me try that
didnt work, heres the error code
17:43:18errorError executing action "inline-ins-31e6413f28.js" in flow:Main:node:product [SyntaxError, Unexpected identifier 'Here'. Expected either a closing ']' or a ',' following an array element.]
q

quiet-hairdresser-14769

07/25/2023, 12:44 AM
hmm...ok let me try running your full code to see
b

bumpy-morning-51656

07/25/2023, 12:47 AM
i got the error message to go away, I put quote marks around the name "Click Here -Fix your sht", and it didnt error m,e, but it just gave me a blank message

https://cdn.discordapp.com/attachments/1133179601636560998/1133198818788249660/image.png

q

quiet-hairdresser-14769

07/25/2023, 12:48 AM
Here you go: if (workflow.whatIssue === 'Dryness (Chap lips, Dry skin)') { workflow.nextMsg2 += '\n For dry skin anywhere on your body, I recommend the "Fix Your Sh*t" Healing Balm. It\'s jam packed with plant based and natural ingredients to soothe your dry skin fast, and comes in various sizes.' workflow.nextMsg3 += "[Click Here - Fix Your Sh*t](https://gingerganics.com/products/fix-your-sht-healing-balm?variant=43060603617509&selling_plan=3903226085)"; }
that should do it, I believe
b

bumpy-morning-51656

07/25/2023, 12:50 AM
holy shit thank you
can you tell me what to change so I don't mess it up next time lol
Just quotations around the entire thing and semi colen at the end?
q

quiet-hairdresser-14769

07/25/2023, 12:51 AM
Yeah, pretty much
And you're welcome, I learned something as well so win-win lol
Well, actually, the brackets we also reversed
so in future try and stick to "[LINK TITLE](URL)"; that format.
b

bumpy-morning-51656

07/25/2023, 12:55 AM
Thats strange, when you are oding it in normal text form the brackets go () [] thats why i got confused