[Botpress] Send content after some time after the first message/event

I want to send a element to the chat if the user has spent a given time say 5 minutes on the chat. So I started with an after_incoming_middleware hook

function hook(bp: typeof sdk, event: sdk.IO.IncomingEvent) { const eventDestination = { channel: event.channel, target: event.target, botId: event.botId, threadId: event.threadId } // Don't process event and send content in 5 minutes if (event.type === "") { event.setFlag(bp.IO.WellKnownFlags.SKIP_QNA_PROCESSING, true) setTimeout(function() { bp.cms.getContentElement('supportbot', 'builtin_card-FvRfLb').then(cardPayload => { bp.events.replyToEvent(eventDestination, cardPayload, event) }) }, 5*60000) } } 

I get an error on cardpayload argument in bp.events.replytoEvent()... The error being Argument of type 'ContentElement' is not assignable to parameter of type 'any[]'

What am I doing wrong? How can I send the card element after a certain time has passed since the first message from the user and what event should I look for/event name in If statement? Also I want the user to be able to continue with the flow after this (shouldn’t interrupt the flow). Tried the BP forum but got no response. Would appreciate some help

submitted by /u/basicnoobie
[link] [comments]