Skip to main content
Version: v1

Web Messenger SDK

The Inbox Web Messenger SDK allows you to implement a customizable, fully featured messenger on your website. Any customer who visits your website or uses your app can contact your support team directly, eliminating the need for your users to use Facebook, WhatsApp, or any other messaging platform.

Create your channel​

Please email customer support (dev.support@hootsuite.com) to add a new messenger channel.

Implement Messenger on your website​

Get started​

The following steps are required to get Messenger to appear on your website.

Step 1: Add the following code toward the end of the <head> section on your page.​

Attention: Make sure to copy all the code below

<script>
!function(e,t,n,o){var r,s,c,a=[],i=[];e[n]={init:function(){r=arguments;var e={then:function(t){return i.push({type:"t",next:t}),e},catch:function(t){return i.push({type:"c",next:t}),e}};return e},on:function(){a.push(arguments)},render:function(){s=arguments},destroy:function(){c=arguments}},e.__onWebMessengerHostReady__=function(t){if(delete e.__onWebMessengerHostReady__,e[n]=t,r)for(var o=t.init.apply(t,r),p=0;p<i.length;p++){var u=i[p];o="t"===u.type?o.then(u.next):o.catch(u.next)}for(s&&t.render.apply(t,s),c&&t.destroy.apply(t,c),p=0;p<a.length;p++)t.on.apply(t,a[p])};try{var p=t.getElementsByTagName("script")[0],u=t.createElement("script");u.async=!0,u.src="https://assets.hootsuite.com/sdk/messenger/web/"+o+"/webmessenger."+o+".min.js",p.parentNode.insertBefore(u,p)}catch(e){console.error(e)}}(window,document,"WebMessenger","2.6.9");
</script>

Step 2: Paste the following initialization code toward the end of the <body> section.​

This initializes a basic Web Messenger without any special customizations. Customizations are described in the next section.

Initialization script

On the third line, insert your specific channel Integration ID. This is one of the pieces of text that is generated on channel creation and will be provided by customer support when the channel is set up.

&lt;script&gt;
var initPromise = WebMessenger.init(\{
integrationId: 'Integration ID here',
// This makes sure the customer is not able to create multiple conversations.
canUserCreateMoreConversations: false,
canUserSeeConversationList: false,

customColors: \{
brandColor: '65758e',
conversationColor: '65758e',
actionColor: '65758e',
\},
menuItems: \{
imageUpload: true,
fileUpload: true,
shareLocation: true
\},
fixedHeader: false,
customText: \{
actionPaymentCompleted: 'Payment Completed',
actionPaymentError: 'An error occurred while processing the card. <br> Please try again or use a different card.',
actionPostbackError: 'An error occurred while processing your action. Please try again.',
clickToRetry: 'Message not delivered. Click to retry.',
clickToRetryForm: 'Form not submitted. Click anywhere on the form to retry.',
connectNotificationText: 'Sync your conversation and continue messaging us through your favorite app.',
connectNotificationSingleText: 'Be notified when you get a reply.',
conversationListHeaderText: 'My conversations',
conversationListPreviewAnonymousText: 'Someone',
conversationListPreviewCarouselText: '\{user\} sent a message',
conversationListPreviewFileText: '\{user\} sent a file',
conversationListPreviewFormText: '\{user\} sent a form',
conversationListPreviewFormResponseText: '\{user\} filled a form',
conversationListPreviewImageText: '\{user\} sent an image',
conversationListPreviewLocationRequestText: '\{user\} sent a location request',
conversationListPreviewUserText: 'You',
conversationListRelativeTimeJustNow: 'Just now',
conversationListRelativeTimeMinute: '1 minute ago',
conversationListRelativeTimeMinutes: '\{value\} minutes ago',
conversationListRelativeTimeHour: '1 hour ago',
conversationListRelativeTimeHours: '\{value\} hours ago',
conversationListRelativeTimeYesterday: 'Yesterday',
conversationListTimestampFormat: 'MM/DD/YY',
conversationTimestampHeaderFormat: 'MMMM D YYYY, h:mm A',
couldNotConnect: 'Offline. You will not receive messages.',
couldNotConnectRetry: 'Reconnecting...',
couldNotConnectRetrySuccess: "You're back online!",
couldNotLoadConversations: 'Couldn’t load conversations.',
emailChangeAddress: 'Change my email',
emailDescription: 'To be notified by email when you get a reply, enter your email address.',
emailFieldLabel: 'Email',
emailFieldPlaceholder: 'Your email address',
emailFormButton: 'Submit',
emailLinkingErrorMessage: 'Please submit a valid email address.',
fetchHistory: 'Load more',
fetchingHistory: 'Retrieving history...',
fileTooLargeError: 'Max file size limit exceeded (\{size\})',
fileTypeError: 'Unsupported file type.',
formErrorInvalidEmail: 'Email is invalid',
formErrorNoLongerThan: 'Must contain no more than (\{characters\}) characters',
formErrorNoShorterThan: 'Must contain at least (\{characters\}) characters',
formErrorUnknown: 'This doesn\'t look quite right',
formFieldSelectPlaceholderFallback: 'Choose one...',
frontendEmailChannelDescription: 'To talk to us using email just send a message to our email address and we\'ll reply shortly:',
headerText: 'How can we help?',
imageClickToReload: 'Click to reload image.',
imageClickToView: 'Click to view \{size\} image.',
imagePreviewNotAvailable: 'Preview not available.',
inputPlaceholder: 'Type a message...',
inputPlaceholderBlocked: 'Complete the form above...',
introAppText: 'Message us below or from your favorite app.',
lineChannelDescription: 'To talk to us using LINE, scan this QR code using the LINE app and send us a message.',
linkChannelPageHeader: 'Sync your conversation',
linkError: 'An error occurred when attempting to generate a link for this channel. Please try again.',
locationNotSupported: 'Your browser does not support location services or it’s been disabled. Please type your location instead.',
locationSecurityRestriction: 'This website cannot access your location. Please type your location instead.',
locationSendingFailed: 'Could not send location',
locationServicesDenied: 'This website cannot access your location. Allow access in your settings or type your location instead.',
messageIndicatorTitlePlural: '(\{count\}) New messages',
messageIndicatorTitleSingular: '(\{count\}) New message',
messageRelativeTimeDay: '\{value\}d ago',
messageRelativeTimeHour: '\{value\}h ago',
messageRelativeTimeJustNow: 'Just now',
messageRelativeTimeMinute: '\{value\}m ago',
messageTimestampFormat: 'h:mm A',
messageDelivered: 'Delivered',
messageSeen: 'Seen',
messageSending: 'Sending...',
messengerChannelDescription: 'Connect your Facebook Messenger account to be notified when you get a reply and continue the conversation on Facebook Messenger.',
newConversationButtonText: 'New Conversation',
notificationSettingsChannelsDescription: 'Sync this conversation by connecting to your favorite messaging app to continue the conversation your way.',
notificationSettingsChannelsTitle: 'Other Channels',
notificationSettingsConnected: 'Connected',
notificationSettingsConnectedAs: 'Connected as \{username\}',
prechatCaptureGreetingText: 'Hi there \nTo start off, we\'d like to know a little bit more about you:',
prechatCaptureNameLabel: 'Your name',
prechatCaptureNamePlaceholder: 'Type your name...',
prechatCaptureEmailLabel: 'Email',
prechatCaptureEmailPlaceholder: 'name@company.com',
prechatCaptureConfirmationText: 'Thanks for that! What can we help you with?',
prechatCaptureMailgunLinkingConfirmation: 'You\'ll be notified here and by email at \{email\} once we reply.',
sendButtonText: 'Send',
settingsHeaderText: 'Settings',
shareLocation: 'Location',
smsBadRequestError: 'We were unable to communicate with this number. Try again or use a different one.',
smsCancel: 'Cancel',
smsChangeNumber: 'Change my number',
smsChannelDescription: 'Connect your SMS number to be notified when you get a reply and continue the conversation over SMS.',
smsChannelPendingDescription: 'Check your messages at \{number\} to confirm your phone number.',
smsContinue: 'Send',
smsInvalidNumberError: 'Please submit a valid phone number.',
smsLinkCancelled: 'Link to \{appUserNumber\} was cancelled.',
smsLinkPending: 'Pending',
smsPingChannelError: 'There was an error sending a message to your number.',
smsSendText: 'Send me a text',
smsStartTexting: 'Start Texting',
smsTooManyRequestsError: 'A connection for that number was requested recently. Please try again in \{minutes\} minutes.',
smsTooManyRequestsOneMinuteError: 'A connection for that number was requested recently. Please try again in 1 minute.',
smsUnhandledError: 'Something went wrong. Please try again.',
syncConversation: 'Sync conversation',
tapToRetry: 'Message not delivered. Tap to retry.',
tapToRetryForm: 'Form not submitted. Tap anywhere on the form to retry.',
telegramChannelDescription: 'Connect your Telegram account to be notified when you get a reply and continue the conversation on Telegram',
uploadDocument: 'File',
uploadInvalidError: 'Invalid file',
uploadPhoto: 'Image',
uploadVirusError: 'A virus was detected in your file and it has been rejected',
unsupportedMessageType: 'Unsupported message type.',
unsupportedActionType: 'Unsupported action type.',
viberChannelDescription: 'Connect your Viber account to be notified when you get a reply and continue the conversation on Viber. To get started, scan the QR code using the Viber app.',
viberChannelDescriptionMobile: 'Connect your Viber account to be notified when you get a reply and continue the conversation on Viber. To get started, install the Viber app and tap Connect.',
viberQRCodeError: 'An error occurred while fetching your Viber QR code. Please try again.',
wechatChannelDescription: 'Connect your WeChat account to be notified when you get a reply and continue the conversation on WeChat. To get started, scan this QR code using the WeChat app.',
wechatChannelDescriptionMobile: 'Connect your WeChat account to be notified when you get a reply and continue the conversation on WeChat. To get started, save this QR code image and upload it in the <a href=\'weixin://dl/scan\'>QR code scanner</a>.',
wechatQRCodeError: 'An error occurred while fetching your WeChat QR code. Please try again.',
whatsappChannelDescriptionDesktop: 'Sync your account to WhatsApp by scanning the QR code or clicking the link below.\nThen, send the pre-populated message to validate the sync request. (Your code: \{\{code\}\}).',
whatsappChannelDescriptionMobile: 'Sync your account to WhatsApp by clicking the link below.\nThen, send the pre-populated message to validate the sync request. (Your code: \{\{code\}\}).',
whatsappLinkingError: 'An error occurred while fetching your WhatsApp linking information. Please try again.'
\}
\}).then(function () \{
// Your code after init is complete
\});
&lt;/script&gt;
Optional functions
// Opens the conversation widget (NOOP when embedded)
WebMessenger.open();

// Closes the conversation widget (NOOP when embedded)
WebMessenger.close();

// Tells if the widget is currently opened or closed.
WebMessenger.isOpened();

// Logs a user in the Web Messenger, retrieving the conversations the user already had on other browser sessions and/or devices. Note that you don't need to call this after `init` if you already passed the external id and jwt as arguments in the call to `init`, in which case it's done internally as part of the initialization sequence. This returns a `Promise` that resolves when the Web Messenger is ready again.
WebMessenger.login('external-id', 'some-jwt');

// Logs out the current user and reinitialize the widget with an anonymous user. This returns a promise that resolves when the Web Messenger is ready again.
WebMessenger.logout();

// Destroys the Web Messenger and makes it disappear. The Web Messenger has to be reinitialized with `init` to be working again because it also clears up the integration id from the Web Messenger. It will also unbind all listeners you might have with `WebMessenger.on`.
WebMessenger.destroy();

// Sends a message to the targeted conversation on the user's behalf.
WebMessenger.sendMessage(
\{
type: 'text',
text: 'hello'
\},
'&lt;conversation-id&gt;'
);
// OR
WebMessenger.sendMessage('hello', '&lt;conversation-id&gt;');

Customize Web Messenger options​

Several options are available for customizing your Web Messenger. The following is an example of a fully customized Web Messenger. Every option used is documented following the code snippet.

Customization options
WebMessenger.init(\{
integrationId: '<integration-id&gt;',
// For authenticated mode
jwt: 'your_jwt',
userId: 'user_id',
locale: 'en-US',
customColors: \{
brandColor: '65758e',
conversationColor: '65758e',
actionColor: '65758e',
\},

menuItems: \{
imageUpload: true,
fileUpload: true,
shareLocation: true
\},

fixedIntroPane: false,

prechatCapture: \{
enabled: true,
fields: [
\{
type: 'email',
name: 'email',
label: 'Email',
placeholder: 'your@email.com'
\},
\{
type: 'text',
name: 'company-website',
label: 'Company website',
placeholder: 'mycompany.com'
\},
\{
type: 'select',
name: 'company-size',
label: 'Company size',
placeholder: 'Choose a number...',
options: [
\{
name: '1-10',
label: '1-10 employees'
\},
\{
name: '11-50',
label: '11-50 employees'
\},
\{
name: '51+',
label: '51+ employees'
\}
]
\}
]
\},
customText: \{
actionPostbackError: 'An error occurred while processing your action. Please try again.',
clickToRetry: 'Message not delivered. Click to retry.',
connectNotificationText: 'Be notified inside your other apps when you get a reply.',
connectNotificationSingleText: 'Be notified when you get a reply.',
connectNotificationSingleButtonText: 'Turn on &lt;name&gt; notifications',
connectNotificationOthersText: 'others',
conversationTimestampHeaderFormat: 'MMMM D YYYY, h:mm A',
fetchHistory: 'Load more',
fetchingHistory: 'Retrieving history...',
fileTooLargeError: 'Max file size limit exceeded (\{size\})',
fileTypeError: 'Unsupported file type.',
headerText: 'How can we help?',
imageClickToReload: 'Click to reload image.',
imageClickToView: 'Click to view \{size\} image.',
imagePreviewNotAvailable: 'Preview not available.',
inputPlaceholder: 'Type a message...',
introductionText: 'We\'re here to talk, so ask us anything!',
invalidFileError: 'Only images are supported. Choose a file with a supported extension (jpg, jpeg, png, gif, or bmp).',
locationNotSupported: 'Your browser does not support location services or it’s been disabled. Please type your location instead.',
locationSecurityRestriction: 'This website cannot access your location. Please type your location instead.',
locationSendingFailed: 'Could not send location',
locationServicesDenied: 'This website cannot access your location. Allow access in your settings or type your location instead.',
messageError: 'An error occurred while sending your message. Please try again.',
messageIndicatorTitlePlural: '(\{count\}) New messages',
messageIndicatorTitleSingular: '(\{count\}) New message',
messageRelativeTimeDay: '\{value\}d ago',
messageRelativeTimeHour: '\{value\}h ago',
messageRelativeTimeJustNow: 'Just now',
messageRelativeTimeMinute: '\{value\}m ago',
messageTimestampFormat: 'h:mm A',
messageSending: 'Sending...',
messageDelivered: 'Delivered',
prechatCaptureGreetingText: 'Hi there \nTo start off, we\'d like to know a little bit more about you:',
prechatCaptureConfirmationText: 'Thanks for that! What can we help you with?',
sendButtonText: 'Send',
settingsHeaderText: 'Settings',
shareLocation: 'Share location',
tapToRetry: 'Message not delivered. Tap to retry.',
unsupportedMessageType: 'Unsupported message type.',
unsupportedActionType: 'Unsupported action type.',
uploadDocument: 'Upload document',
uploadInvalidError: 'Invalid file',
uploadPhoto: 'Upload photo',
\}
\}).then(function() \{
// Your code after init is complete
\});

initPromise.then(function() \{
// do something
\});

// pass it around...
initPromise.then(function() \{
//do something else
\});

Options​

The following general settings can be changed.

OptionOptional?Default valueDescription
integrationIDNo-Your integration ID.
regionYes-The target region in which the app is located.
jwtYes-The token to authenticate your communication with the server.
userIdYes-The user's ID.
authCodeYes-An auth code for linking to an existing conversation.
localeYesen-USThe locale used for date formatting using the - format. See language codes and country codes.

Note: The country part is optional, and if a country is either not recognized or not supported, the app falls back to the generic language. If the language isn't supported, the app falls back to en-US.

Note: This is only used for date formatting and doesn't provide built-in translations for Web Messenger.
soundNotificationEnabledYesTRUEEnables the sound notification for new messages.
imageUploadEnabledYesTRUEEnables the image upload feature.
embeddedYesFALSETells the widget it is embedded (see following Embedded section).
displayStyleYesbuttonHow the messenger appears on your website. Must be either button or tab.
buttonIconUrlYes-When the displayStyle is "button", you can select your own button icon. The image must be at least 200 x 200 pixels in JPG, PNG, or GIF format.
buttonWidthYes58pxWhen the displayStyle is "button", you have the option of specifying the button width.
buttonHeightYes58pxWhen the displayStyle is "button", you have the option of specifying the button height.
businessNameYes-A custom business name.
businessIconUrlYes-A custom business icon URL. The image must be at least 200 x 200 pixels and must be in JPG, PNG, or GIF format.
backgroundImageUrlYes-A background image URL for the conversation. The image is tiled to fit the window.
customColorsYesSee the following sectionColors used in the Web Messenger UI.
customTextYesSee the following exampleStrings used in the Web Messenger UI. You can use these to either customize the text or translate it.

Note: Some strings include variables (surrounded by {}), which must remain in your customized text.
menuItemsYesSee the following section
prechatCaptureYesSee the following section

Color options​

You can give your Web Messenger a custom look by editing the following settings.

OptionOptional?Default valueDescription
brandColorYes65758eThis color is used in the messenger header and the button or tab in idle state. Must be a 3- or 6-character hexadecimal color.
conversationColorYes0099ffThis color is used for customer messages, quick replies, and actions in the footer. Must be a 3- or 6-character hexadecimal color.
actionColorYes0099ffThis color is used for calls-to-action inside your messages. Must be a 3- or 6-character hexadecimal color.

Text options​

Web Messenger has many text options to choose from. Here are a few examples.

OptionDefault value if not used
actionPostbackErrorAn error occurred while processing your action. Please try again.
clickToRetryMessage not delivered. Click to retry.
connectNotificationTextBe notified inside your other apps when you get a reply.
connectNotificationSingleTextBe notified when you get a reply.
connectNotificationSingleButtonTextTurn on <name> notifications
connectNotificationOthersTextothers
conversationTimestampHeaderFormatMMMM D YYYY, h:mm A
fetchHistoryLoad more
fetchingHistoryRetrieving history...
headerTextHow can we help?
inputPlaceholderType a message...
introductionTextWe're here to talk, so ask us anything!
invalidFileErrorOnly images are supported. Choose a file with a supported extension (jpg, jpeg, png, gif, or bmp).
locationNotSupportedYour browser does not support location services or it's been disabled. Please type your location instead.
locationSecurityRestrictionThis website cannot access your location. Please type your location instead.
locationSendingFailedCould not send location
locationServicesDeniedThis website cannot access your location. Allow access in your settings or type your location instead.
messageErrorAn error occurred while sending your message. Please try again.
messageIndicatorTitlePlural({count}) New messages
messageIndicatorTitleSingular({count}) New message
messageRelativeTimeDay{value}d ago
messageRelativeTimeHour{value}h ago
messageRelativeTimeJustNowJust now
messageRelativeTimeMinute{value}m ago
messageTimestampFormath:mm A
messageSendingSending...
messageDeliveredDelivered
sendButtonTextSend
settingsHeaderTextSettings
tapToRetryMessage not delivered. Tap to retry.
unsupportedMessageTypeUnsupported message type.
unsupportedActionTypeUnsupported action type.
uploadDocumentUpload document.
uploadInvalidErrorInvalid file.
uploadPhotoUpload photo.

Menu items can be enabled or disabled.

OptionOptional?Default valueDescription
imageUploadYesTRUEEnables the image upload menu item
fileUploadYesTRUEEnables the file upload menu item
shareLocationYesTRUEEnables the share location menu item

Prechat capture option​

This option allows you to have the Web Messenger automatically post a message to the user. You can implement a variety of messages. The following code snippet is the same as the one used in the earlier example.

prechatCapture: {
enabled: true,
fields: [
{
type: 'email',
name: 'email',
label: 'Email',
placeholder: 'your@email.com'
},
{
type: 'text',
name: 'company-website',
label: 'Company website',
placeholder: 'mycompany.com'
},
{
type: 'select',
name: 'company-size',
label: 'Company size',
placeholder: 'Choose a number...',
options: [
{ name: '1-10', label: '1-10 employees' },
{ name: '11-50', label: '11-50 employees' },
{ name: '51+',label: '51+ employees' }
]
}
]
}

Embedded mode option​

You have the option to set up the Web Messenger in an embedded mode. This lets you choose where you want the widget to be visible. The following example illustrates what you need to set it up. Note that for embedded mode to work, you must set the parameter of embedded to true and call the WebMessenger.render() function manually.

WebMessenger.init({
integrationId: 'INTEGRATION_ID_HERE',
embedded: true
}).then(() => {
// Your code after init is complete
});

WebMessenger.render(document.getElementById('chat-container'));

This sample embeds the Inbox 2.0 messenger within a DOM element with the ID "chat-container". If you open the webpage, you will notice that it is no longer showing a button on the bottom right, but it is visible in the container element.

Use contact attributes to save specific messenger data​

You can store information about the webpage and the user by using contact attributes. To enable this, do the following:

  1. Go to Admin settings, expand Agent workspace, and then select Contact attributes.
  2. Find one of the default contact attributes in the list and use the toggle to enable it.

Now, when a client contacts you via the WebMessenger Messenger plugin, that specific data will be stored inside of a contact attribute.

Available contact attributes for the Web Messenger plugin:

  • Browser Language
  • First Name
  • Last Name
  • Page Domain
  • Page Title
  • Page URL
  • User Id

Use shortcodes to create a rich messaging experience​

Shortcodes are a useful way to create a rich messaging interface.

Available shortcodes​

ElementSyntaxExample
Link button%[]()%[Button label](http://anyurl.com)
Reply button%[](reply:)%[Button label](reply:PAYLOAD)
Location request button%[](location)%[Button label](location)
Image![]()![](http://url-of.the/image.jpg)

By using multiple Link button shortcodes, you can send a contact multiple links in one message. An example:

%[Link to Facebook](https://facebook.com)
%[Link to Twitter](https://twitter.com)
%[Link to LinkedIn](https://linkedin.com)

A sample message with three link buttons

Reply button​

By using multiple Reply button shortcodes under each other in one message, you can offer the contact a choice. For example:

%[Sales](reply:Sales)
%[Support](reply:Support)
%[Engineering](reply:Engineering)

A sample message with three reply buttons

Location sharing button​

This code allows you to invite the contact to share their location with you.

%[Share your location with us](location)

A sample message with a request to share the location

Images​

You can send images and gifs using this shortcode.

![A sample message with a GIF](http://url-of.the/image.gif)

A sample message with a GIF