Gorgias logo
Gorgias logo

All articles

Programmatically send a messageUpdated a month ago

This suggestion isn't an official feature of our Chat widget, so our support for it is limited - we recommend that it be implemented by someone with a technical background.


To send a message from the user via the Chat programmatically, you can use this method with a string parameter:

1<script>
2var initGorgiasChatPromise = (window.GorgiasChat) ? window.GorgiasChat.init() : new Promise(function (resolve) { window.addEventListener('gorgias-widget-loaded', function () { resolve();})});
3
4initGorgiasChatPromise.then(function() {
5 GorgiasChat.sendMessage('the message')
6})
7</script>

If the Chat is still closed, the message will wait for the user to open it before sending. If the Chat always remains closed, the message will never be sent. 

If you want to send a message no matter what, force the opening of the Chat first with GorgiasChat.open().

Was this article helpful?
Yes
No