https://discord.gg/botpress logo
execute code does not work
# šŸ¤help
c
Hi guys I just started using Botpress and wanted to create a simple bot that sends a text message in response using the Execute Code block after the start. However, I’m getting an error (there are no errors in the code). I’ve tried everything, has anyone encountered this issue? What should I do? I’m using the Botpress cloud service and it seems like I missed something in the basic settings, but I can’t figure out what needs to be done.
w
hi ! can you share the code you are using ?
c
Sure. It is really simple as I wanted just to get know how this function works. Here: > const response = 'Hi! How can I help you?'; > bp.events.replyToEvent(event, [ > { > type: 'text', > text: response > } > ]);
I spent several hours on this today and I feel really stupid..)
w
okay, and do you know where is the doc for that ? I must admit that I have never really succeed in making work those kind of events in an execute code card
c
What do you mean by ā€œthe doc for thatā€? That’s why I used simple code, because I didn’t have to check connections with external libraries/sources. It seemed to me that it would work like that. You still need some kind of document, are you talking about that?
w
I mean did you copy and paste these lines of codes from somewhere ?
c
Yeah I used ChatGPT to@create it. But it looks quite obvious. I also tried another (form YouTube video made by botpress) - the result was the same
w
Indeed, so you took the syntax bp.events.replyToEvent from the yt video ?
I think that there is a tutorial for creating dynamic carousel that is actually using this syntax so maybe you can have a look at it
c
OMG, I finally made it! Thank you so much for your willingness to help. I really appreciate it!
w
Really nice to hear !
Can you share the final code ?
c
Sure, the code above is from ChatGPT. The code I had from YouTube was incorrect because I used an AI tool, and mine didn't match what was shown in the video, leading to the mistake. Here is the code: > const currentDate = luxon.DateTime.now().toLocaleString(luxon.DateTime.DATE_FULL) > workflow.Date = currentDate
but before you also need to create variable Date
w
I mean the code to send a message from an execute code card šŸ˜…
c
Yes, but I don’t have a working code like that yet :)) However, I think I’ll figure it out today. If anything, I’ll send it to you.
w
Oh okay I thought you had a working code for that
3 Views