Check session age

How can I check session age in after_incoming_middleware_hook and then send a payload/card? I can’t find what property is responsible in SDK for storing session age.

Here is a poor attempt of me trying to check how long it’s been since the user had started the session and attempting to send a contentElement. Yikes. image — ImgBB

The point of this hook is try to assist users who’ve been using the bot for a while (3 mins) and send a WhatsApp Business link for human support.

Would appreciate some assistance.

Hi @sentientAI,

You can have a look on the Proactive Hooks.

They allow you to send a message proactively to the user.

However for the time I guess your idea was not so bad, you can put an Interval or a Timeout or as you did by looking the age of the event.

Hope it helps,
Have a good day !

1 Like

Thanks Pierre! How can I send a content element in response to an event? What’s wrong with my code?