JavaScript API: How can I get the chatID of the chat currently taking place?

Hi everyone,

When a user starts a chat on the site is there anyway to extract the Tawk.to chatID (usually in this format “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”) so that we can use this on the page itself?

For example, when a chat starts on the site we are looking to develop something (using the existing onChatStart() method) that will take various bits of data from the page and submit it to our own webhook.

I understand that there is webhook functionality already in the dashboard, however we need additional information that is on the page to be submitted at the same time, but we just need to know the chatID of the current chat that is happening on the page to make this work.

Thanks

Hi MartinMc,

Thank you for reaching out.

This should help:

Let us know if you have any other questions.

@Ralph - the visitor identifier and the chat ID don’t appear to be the same thing.

The data from the webhooks have this field called chatId

Is there a way to get this value in the JavaScript API?

It isn’t provided in onChatStarted or on the onPrechatSubmit when the session is initiated. Is there a way to get it from the JavaScript API?