https://discord.gg/botpress logo
Reply message in Action
# 🤝help
t
I want to send a message in custom action, is bot press can do that??? And how to do that, thank you
p
This is code you can use within an execute code card or an action to send a message:
Copy code
javaScript
const textMessage = 'Here is your message!' // Message to send before the button

// Send a text message to the user
await client.createMessage({
  conversationId: event.conversationId,
  userId: event.botId,
  tags: {},
  type: 'text', // Set type to 'text' for text message
  payload: {
    text: textMessage // Set the text message content
  }
})
t
thank you so much @prehistoric-airplane-85682
Sorry but can i send messages as a carousel
a
Where are things like these documented? It's so hard to find out how to use custom code as there's no documentation on what variables, packages, methods etc. are available
p
Here's the execute code card docs: https://botpress.com/docs/learn/reference/cards/execute, if you would like to see more information I'd be happy to communicate it to the right person but please be specific as to what is missing.
a
If I use the example above to send a text message from an action, the code executes successfully but no message is showing up (using the exact snippet from above). How can I send the message correctly using an action?
Did you figure this out?
p
You cannot call an action.
a
Not calling an action, but sending a carousel message from the action code. It just doesnt send anything to the chat (emulator)
p
Yeah, unfortunately, only text messages can be sent programmatically as of now.