Proactive actions in version 11.3

#1

hi…i would like to pop a message saying that…" hi i’m bot… i would like to help you"
i have created created a hook like —>

welcome.js (hook)
“use strict”
const _ = require(‘lodash’)

if (event.type === ‘proactive-trigger’) {
const payloads = await bp.cms.renderElement(‘builtin_text’, { text: “Hey there!I’m Laudea bot”, typing: true }, event.channel)
console.log(payloads)
bp.events.replyToEvent(event, payloads)
}

and the bot is embedded to a website like

still i could not pop the desired message .whats wrong?
please help with this.

Images not appearing in Card & Carousels
#2

Your snippet looks alright at first sight. Are you sending the proactive-trigger from the website? If so can you post your snippet here?

#3

yes i’m adding the following snippet to the index.html page of the website ,where i host my bot.

src=“http://localhost:3002/assets/modules/channel-web/inject.js
window.botpressWebChat.init({ host:‘http://localhost:3002’, botId:‘botId’})
window.botpressWebChat.sendEvent({ type: ‘show’ })
window.botpressWebChat.sendEvent({
type: ‘proactive-trigger’,
channel: ‘web’,
payload: {
text: ’ ’
}
})

#5

As per last developer documentation

https://botpress.io/reference/modules/_botpress_sdk_.cms.html#renderelement

you must pass the event object to renderElement method
Also to get the payload value you have to get it by

event.payload.payload.payload.text;

example

“use strict”;

const setProactive = async () => {

if (event.type === ‘proactive-trigger’) {
bp.logger.warn( `Just received a postback event: ${event.target} ${event.payload.payload.payload.text}` );
// Sends a basic text message
const payloads = await bp.cms.renderElement(‘builtin_text’, {
text: event.payload.payload.payload.text,
typing: true
}, event);
await bp.events.replyToEvent(event, payloads);

}
};

return setProactive();