Search by keyword, such as: divert, calls, chats …

An intro to Javascript

This article will lay out how to set up dynamic proactive messages.

Dynamic Proactive (and bot) messages

Proactive chats are great at increasing engagement with your web visitors and clients. The best way to get more engagement from chats is to make sure your messages are personalised and highly contextual. To make these messages even more targeted, make sure they are dynamic and have variable content. This can easily be done by passing data from your site or application into Moneypenny chat using JavaScript variables. You can then insert this data into your messages. 

Use Case Examples

If you’re already using JavaScript variables to capture information, then you might as well use them to customise the messages from Moneypenny chat further! If you can see the name of the visitor, use it. It makes the message far more personalised if you add their name at the end of your greeting: ‘Hello {js:clientname}’ would become ‘Hello Billy’. You could also use their name with other personalised messages. Say they have an account with you and you can see the subscription is coming to an end, you could send them a message saying ‘Hi Billy, I can see your subscription is due to expire on 21st November, do you need any help to renew it?’

The above example would be based on a rule to trigger if the subscription date is in the next 10 days for example (based on variables you capture), and then the name and the date will populate. The text for this rule would look similar to this: ‘Hello {js.clientname}, I can see your subscription is due to expire on ‘{js.subscriptionendfate}, do you need any help to renew it?’ The trigger would also be done with a JavaScript rule.

For a more specific example, let’s say you’re a shoe shop. If one of your web visitors is looking at a certain pair of shoes, you can prompt a proactive chat that says something like ‘I can see you’re looking at the Amazingshoe 11, would you like further information?’. For a message like this one to prompt you’ll need to pass the variable, in this case the model of the shoe, to Moneypenny chat as a JavaScript variable. If you haven’t set a variable, you can have a fall-back text to display, which in this case would be ‘trainers’. If there’s no variable set, the message will read as ‘I can see you’re looking at trainers, would you like further information?’

The set up for this would be as follows: {js:trainersmodel||trainers}

If you’re able to get the variable, it’ll look something like this:

If you’re missing the variable, it will look like this picture:

Setting up JavaScript Variables

You will need the right data available on your site or application to use these JavaScript variables. You’ll then need to set the value you want globally within the pages where your Moneypenny chat widget is installed. If you need any help with this, ask your website or application developers. 

On the Moneypenny chat admin side, you’ll need to add the JavaScript variable under the ‘Options’ tab. Make sure you enable the ‘Collect additional information’ checkbox and then type the name of the required variable in the box.

Setting up Dynamic Messages

When the above has been done pop over to Settings – > Proactive chat, and then add a proactive chat configuration. This is when you add the rules you want to use, and on the message type your JavaScript variable in the sentence. Don’t forget that you’re able to trigger proactive prompts based on various JavaScript variables.

For the above example, if you don’t have a value you’ll want it to default to ‘trainers’, so the message will still make sense. The above is just an example, there are so many options out there that can help your business!

We give you amazing people and technology:


Your own Moneypenny PA to answer calls exactly as if based in your office.

Discover >
Live Chat

Amazing people, briefed by you to manage chats whenever you can't.

Discover >
Pocket Phone System

All the functions and support of an office phone system, minus the hardware.

Discover >