Create valid Messaging Session with Apex for outbound WhatsApp message

206 Views Asked by At

Today I have a Apex job that send multiple messages every couple of minutes.

So.. if the reciever don't has a related MessagingEndUser I do create it before send the message, I apply some bussiness rules and send a message with a custom Flow we created. Everything is ok if the receiver interact with the org WhatsApp MessagingChannel, he wil recive every message.

But if he didn't Salesforce will try it, it creates the MessagingSession record but it's created ended and Salesforce print a error on the MessagingSession record "We can’t send this message because it timed out. You can start the new conversation when the user contacts you again.

I did search and didn't found any workaround or anyone saying something about it. At the end, I need just to send a message with Apex code if there is no active Messaging Session too.

I already tried create the MessagingSession before send the message, but Salesforce just ignores the new record, create another one ended and don't send any message.

0

There are 0 best solutions below