How to send images using hooks in Botpress

Can anyone help me to give an example of sending images from hooks?


In this example, I use an “after incoming middleware” hook to send a message in case the user visits the chat window :

async function hook() {
    if (event.type === 'visit') {, await bp.cms.renderElement('!builtin_image-aC3C1x', {}, event))

return hook()

The element string should be the id of your contentElement

1 Like

thank you so much. It works

I don’t understand the concept of middleware and Before Outgoing Middleware
Could you help me with it?

@rezwanahmed, a middleware in botpress is some custom code that is executed between botpress events.

Like before_incoming means “Run my custom code before giving the message to botpress in which it will then pass all the rest of the pipeline”.

Hope it helps,
Have a great day

1 Like