January 11, 2022

How to create and update contact via JS

You can easily update already existing contact’s data and add a new one using JavaScript.

To update the contact’s data in the Contact List or to create a new one, you need to properly identify your user and fire an event on your web page.

IMPORTANT: Include those snippets on every page in your app, immediately before the closing </body> tag to initialize JS API and identify your user.

Connecting the library:

                <script type="text/javascript" src="//js.wooxy.com/js/v2/JS_SCRIPT_ID.js" charset="UTF-8">

</script>
            

Contact identificator:

                <script type="text/javascript">

    let contact = new _wooxyContact('{{identifier}}');

</script>
            

Step-by-step instructions:

  • To add a new user to the Contact List see example:
    Icon caret

    <script type="text/javascript"> 
       contact.Add({ 
           name: "John Doe", 
           email: "user@example.com", 
           phoneNumber: "+15555555", 
           userId: "myUserId", 
           active: true, 
           emailSubscribe: true, 
           smsSubscribe: true, 
           viberSubscribe: true, 
           firstName: "John", 
           lastName: "Doe", 
           contactBirthday: "YYYY-MM-DD", 
           contactLanguage: "en", 
           contactGender: "female", 
           contactTimezone: "Europe/Tallinn", 
           contactScore: 100, 
           avatarLink: "https://img.wooxy.com/g/06c38b4568.jpg", 
           facebookLink: "https://facebook.com/wooxy.com", 
           instagramLink: "https://instagram.com/wooxy", 
           linkedInLink: "https://linkedin.com/company/wooxy", 
           twitterLink: "https://twitter.com/wooxy", 
           tiktokLink: "https://tiktok.com/wooxy", 
           sourceId: "Source_ID_from_Wooxy", 
           customerSourceId: "Customer_Source_ID_From_Your_Platform", 
           cac: { 
               value:      2.05, 
               currency:   "USD", 
           }, 
           variables: [ 
               {name: "stringVariableName", value: "newVariableValue"}, 
               {name: "dateVariableName", value: "YYYY-MM-DD"} 
           ], 
       }); 
    </script>

    Parameters
    contact 'required'An array of contact information.

    name 

    'optional'

    The optional display name to use for the recipient.

    email 

    'optional'

    Contact’s email address.
    phoneNumber 'optional'IMPORTANT: should be valid E.164 phone number format.

    userId 

    'optional'

    Contact’s unique user ID from your platform to enable management of the contact in the list based on it.

    active 

    'optional'

    You can set if the contact is enabled contact list or not. The default value is false (disabled).
    true 'optional'Contact enabled. Contact can receive communication from enabled channels.
    false 'default'Contact disabled. No communications will be sent to this contact.
    emailSubscribe 'optional'You can set if the contact is subscribed to receiving emails or not. The default value is false (unsubscribed).
    true 'optional'Subscribe contact to emails receiving.
    false 'default'Unsubscribe contact from emails receiving.
    smsSubscribe 'optional'You can set if the contact is subscribed to receiving SMS or not. The default value is false (unsubscribed).
    true 'optional'Subscribe contact to SMS receiving.
    false 'default'Unsubscribe contact from SMS receiving.
    firstName 'optional'Contact’s first name.
    lastName 'optional'Contact’s last name.
    contactBirthday 'optional'Contact’s birth date in ENUM_DATE (YYYY-MM-DD) format.
    contactLanguage 'optional'Contact’s locale in ISO 639-1 format
    contactGender 'optional'Contact’s gender in ISO/IEC 5218 format
    0Not known
    1Male
    2Female
    9Not applicable
    contactTimezone 'optional'Contact’s timezone in ISO 8601 format
    contactScore 'optional'Contact Score.
    avatarLink 'optional'Link to contact’s avatar image.
    facebookLink 'optional'Link to contact’s Facebook profile.
    instagramLink 'optional'Link to contact’s Instagram profile.
    linkedInLink 'optional'Link to contact’s LinkedIn profile.
    twitterLink 'optional'Link to contact’s Twitter profile.
    tiktokLink 'optional'Link to contact’s TikTok profile.
    variables 'optional'An array of contact variables and their values.
    name 'required'Variable name in lowerCamelCase format. WARNING: Please use only Latin lowerCamelCase format. No numbers or other symbols are allowed.
    value 'required'Variable value in 'ENUM_STRING' or 'ENUM_DATE' (YYYY-MM-DD) format correspondingly.
    sourceId 'optional'Contact’s unique source ID from Wooxy.com platform.
    customerSourceId 'optional'Contact’s unique source ID from your system to synchronize two sides.

    cac 

    'optional'

    value 'required'CAC value in 'ENUM_STRING' format correspondingly.
    currency 'required'(EUR, USD) WARNING: Please use only Latin uppercase format. No numbers or other symbols are allowed.
  • To update contact data in the Contact List see example:
    Icon caret

    <script type="text/javascript"> 
       contact.update({ 
           name: "John Doe", 
           email: "user@example.com", 
           phoneNumber: "+15555555", 
           userId: "myUserId", 
           active: true, 
           emailSubscribe: true, 
           smsSubscribe: true, 
           viberSubscribe: true, 
           firstName: "John", 
           lastName: "Doe", 
           contactBirthday: "YYYY-MM-DD", 
           contactLanguage: "en", 
           contactGender: "female", 
           contactTimezone: "Europe/Tallinn", 
           contactScore: 100, 
           avatarLink: "https://img.wooxy.com/g/06c38b4568.jpg", 
           facebookLink: "https://facebook.com/wooxy.com", 
           instagramLink: "https://instagram.com/wooxy", 
           linkedInLink: "https://linkedin.com/company/wooxy", 
           twitterLink: "https://twitter.com/wooxy", 
           tiktokLink: "https://tiktok.com/wooxy", 
           sourceId: "Source_ID_from_Wooxy", 
           customerSourceId: "Customer_Source_ID_From_Your_Platform", 
           cac: { 
               value:      2.05, 
               currency:   "USD", 
           }, 
           variables: [ 
               {name: "stringVariableName", value: "newVariableValue"}, 
               {name: "dateVariableName", value: "YYYY-MM-DD"} 
           ], 
       }); 
    </script>

    Parameters
    USER_UNIQUE_IDENTIFIER 
    'required'
    The 'email' address, 'userId' or 'phoneNumber' of the recipient stored in the DefaultContactList.
    contact  
    'required'
    An array of contact information want to update.
    name  
    'optional'
    The optional display name to use for the recipient.
    email  
    'optional'
    Contact’s email address.
    phoneNumber  
    'optional'
    IMPORTANT: should be valid E.164 phone number format.
    userId  
    'optional'
    Contact’s unique user ID from your platform to enable management of the contact in the list based on it.
    active  
    'optional'
    You can set if the contact is enabled contact list or not.  
    The default value is false (disabled).
    true  
    'optional'
    Contact enabled. Contact can receive communication from enabled channels.
    false  
    'default'
    Contact disabled. No communications will be sent to this contact.
    emailSubscribe  
    'optional'
    You can set if the contact is subscribed to receiving emails or not.  
    The default value is false (unsubscribed).
    true  
    'optional'
    Subscribe contact to emails receiving.
    false  
    'default'
    Unsubscribe contact from emails receiving.
    smsSubscribe  
    'optional'
    You can set if the contact is subscribed to receiving SMS or not.  
    The default value is false (unsubscribed).
    true  
    'optional'
    Subscribe contact to SMS receiving.
    false  
    'default'
    Unsubscribe contact from SMS receiving.
    desktopWebPushSubscribe  
    'optional'
    You can set if the contact is subscribed to receiving desktop web push notifications or not.  
    The default value is false (unsubscribed).
    true  
    'optional'
    Subscribe contact to desktop webpush notifications.
    false  
    'default'
    Unsubscribe contact from desktop webpush notifications.
    mobileWebPushSubscribe  
    'optional'
    You can set if the contact is subscribed to receiving mobile web push notifications or not.  
    The default value is false (unsubscribed).
    true  
    'optional'
    Subscribe contact to mobile webpush notifications.
    false  
    'default'
    Unsubscribe contact from mobile webpush notification.
    telegramSubscribe  
    'optional'
    You can set if the contact is subscribed to receiving Telegram messages or not.  
    The default value is false (unsubscribed).
    true  
    'optional'
    Subscribe contact to Telegram messages.
    false  
    'default'
    Unsubscribe contact from Telegram messages.
    firstName  
    'optional'
    Contact’s first name.
    lastName  
    'optional'
    Contact’s last name.
    contactBirthday  
    'optional'
    Contact’s birth date in ENUM_DATE (YYYY-MM-DD) format.
    contactLanguage  
    'optional'
    Contact’s locale in ISO 639-1 format
    contactGender  
    'optional'
    Contact’s gender in ISO/IEC 5218 format
    0Not known
    1Male
    2Female
    9Not applicable
    contactTimezone  
    'optional'
    Contact’s timezone in ISO 8601 format
    contactScore  
    'optional'
    Contact Score.
    avatarLink  
    'optional'
    Link to contact’s avatar image.
    facebookLink  
    'optional'
    Link to contact’s Facebook profile.
    instagramLink  
    'optional'
    Link to contact’s Instagram profile.
    linkedInLink  
    'optional'
    Link to contact’s LinkedIn profile.
    twitterLink  
    'optional'
    Link to contact’s Twitter profile.
    tiktokLink  
    'optional'
    Link to contact’s TikTok profile.
    variables  
    'optional'
    An array of contact variables and their values.
    name  
    'required'
    Variable name in lowerCamelCase format.  
    IMPORTANT: Please use only Latin lowerCamelCase format. No numbers or other symbols are allowed.
    value  
    'required'
    Variable value in 'ENUM_STRING' or 'ENUM_DATE' format correspondingly.
    sourceId  
    'optional'
    Contact’s unique source ID from Wooxy.com platform
    customerSourceId  
    'optional'
    Contact’s unique source ID from your system to synchronize two sides. IMPORTANT: If you use sourceId and customerSourceId at the same time, sourceId will have higher priority.
    cac  
    'optional'
    value  
    'required'
    CAC value in 'ENUM_STRING' format correspondingly.
    currency  
    'required'
    (EUR, USD)  
    IMPORTANT: Please use only Latin uppercase format. No numbers or other symbols allowed.