How to Transfer Custom Variables During a Subscription to a Chatbot

Integrating SendPulse with messengers allows you to transfer custom variables to your SendPulse account when someone subscribes via a widget or following a link. With the help of this functionality, you can pass values ​​for existing variables in the "Audience" tab of the chatbot.

Please note that to transfer variables, you need to create them in the "Audience" tab first. Data sent to non-existent fields will be disregarded.

The transfer of variables when subscribing to a chatbot using a widget or via a link only works for Facebook, Telegram, and VKontakte chatbots as of now. When subscribing to Instagram and WhatsApp chatbots, you cannot transfer custom variables since social networks do not support this possibility.

When Subscribing Via a Widget

You can configure the transfer of variables from your site, where you installed the widget, in two ways.

Method 1

After adding the code of a Facebook chat widget, add the following code to the site:

<script type="text/javascript">
    window.oSpP = {
        phone: '+123123123',
        email: '',
        name: "Olga",
        city: "Odessa"

If customers subscribed to the chatbot and after that the {{phone}}, {{email}}, {{city}} and {{name}} variables were added for these customers. Their data will not be transferred to the SendPulse account.

Please note: if you added a method for passing additional variables for web push notification subscribers using window.oSpP, there may be conflicts with the widget for collecting additional variables for the chatbot, and widget may not work.

Method 2

Add additional input fields with the sp_push_custom_data class to the site:

<input type="hidden" name="email" class="sp_push_custom_data " value="">
<input type="hidden" name="phone" class="sp_push_custom_data " value="+123123123">
<input type="hidden" name="name" class="sp_push_custom_data " value="Olga">
<input type="hidden" name="city" class="sp_push_custom_data " value="Odessa">

Both methods are universal for sites on any CMS.

When Subscribing by Clicking on the Link

You can also pass variables when subscribing to a bot by inserting variables into the link to the bot via the ?ref (for Facebook and VKontakte) or ?start (for Telegram) parameter, separating the variables with the | sign.

Using this mechanism, you can transfer UTM-tags, email addresses, phone numbers, or other variables. When clicking on the link and starting the dialogue, the variable values are recorded for a specific subscriber in the chatbot audience.

For example, a link for a Facebook chatbot will look like this:{page_id}?ref={flow_id}|var1_name=value1|var2_name=value2

Where flow_id is the flow ID, var_name is the variable's name, and value is the value to be passed. All given parameters in the example are optional.

For the Telegram chatbot link, it is also necessary to add the intermediate domain "" because Telegram has a restriction on the format and size of the transmitted data. The link will look like this:{bot_name}?start={flow_id}|var1_name=value1|var2_name=value2
Rate this article about "How to Transfer Custom Variables During a Subscription to a Chatbot"

User Rating: 4 / 5 (7)

    Popular in Our Blog

    Try a free chatbot for Facebook Messenger