restviberviber-api

How to get message by message_token using Viber REST API?


I'm building the Viber bot which will be served using different services. One of the problem is about getting the exact message which has been sent to the user.

The "received" event gives message_token, so I wonder if it's possible to use it in order to get the message.

Or I have to use my own mechanism of sync?


Solution

  • Viber message_token is an identifier for peer-2-peer connection between Viber server and/or your local or online server and not the actual message. Moreover, there is no "buffer" for messages to be stored both locally or online. There is an internal process to store message when recipient is offline and then resend message when it is got online but I couldn't find direct access to them.

    I did something similar by storing incoming messages to SQL using datetime (milliseconds) as timestamp in order to identify the message. However, you can combine Token also for knowing the session or to be more specific user_ID, both are unique.

    Hope that helps to work around your problem...