Desktop Integration

Installation

1. To get access to Chatbot please include the following script tag in your website’s HTML.

<script src="https://cdn5.synapsefi.com/initialize.js"></script>

2. In order to initialize the Chatbot you must invoke the Synapse.create function, passing in a configuration object. The configuration object is required.

Parameters to Initialize Chatbot for Desktop

Parameter ‌‌  ‌‌  ‌‌ ‌‌  ‌‌  ‌‌  ‌‌  ‌‌  ‌‌  ‌‌Description
defaultPath[Required]
'ROUTER' For Chatbot Router
'CARDS' For Card Management
'EDD' For Enhanced Due Diligence
'BANK_LOGINS' or 'BUSINESS_BANK_LOGINS' For Linking Bank Credentials
'INTERCHANGE' For Linking/Unlinking Cards
env[Required] The Synapse API environment on which to create user accounts. For development use UAT, and use production for Production.
generatePublicKey[Required] A callback function that returns a public key(string).
generateFp[Required] A callback function that returns a valid device fingerprint(string).
generateUserId[Required] A callback function to get a user ID(string).
onErrorA callback function that returns an error code and description when user encounters an API error.
onExitA callback function that returns the specified message when the user exits the Chatbot flow.
institutionBank_code of the Institution that the user wants to link (eg ‘bofa’). This feature allows to skip a select bank step.

Configuration object:

Please note, the defaultPath will be one of the following:

  • ROUTER
  • EDD
  • BANK_LOGINS
  • BUSINESS_BANK_LOGINS
  • INTERCHANGE
  • CARDS
var configuration = {
  
     defaultPath: 'ROUTER',  // (required)
  
     generatePublicKey: function() {
       // (required) a callback function that generates and returns the public key(string)
       return 'public_key'
     },
  
     generateFp: function() {
       // (required) a callback function which returns the user fingerprint(string)
       return 'fingerprint'
     },
  
     generateUserId: function() {
       // (required) a callback function that gets a user ID(string)
      return 'user_id'
     }, 
  
     env: 'UAT', // (required) can be 'production' or 'UAT' (sandbox),

     onSuccess: function(data){
		// (optional) callback that is called when a user linked accounts successfully, data object contains info about the institution the user selected and the account ID or IDs, the userId and step name
	}, 

     onError: function(data){
	// (optional) callback that is called when a user encountered an API error, data object contains info about error code, http code, error message, userId, time and step name
      }, 

     onExit: function(data){
	// (optional) callback that is called when a user exit chatbot, data object contains info about the institution the user selected, userId and step name
	},
  institution: 'bank_code' // (optional) passing bank_code lets skip a select bank step
}
Synapse.create(configuration);

3. Next, you need to open the chatbot, which can be done by invoking the Synapse.open function.

Example: Invoking the function on a click of a button

$('#buttonId').on('click', function() { //ID of the button that would trigger Chatbot. 
    Synapse.open();
});

Example: Invoking the function when the page is loading

Synapse.open();

Example of the whole HTML file

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width" />
 <title>Synapse</title>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
 <script src="https://cdn5.synapsefi.com/initialize.js"></script>
 ...
</head>

<body>
<button id="link-button">Open Chatbot</button>
 <script>
   
   var configuration = {
   
     defaultPath: 'ROUTER',
     
     generatePublicKey: function() {
       return 'public_key_qWCwNJcVPT2jMY105s7K6bUDm3gixoXkf94ZrR8F'
     },
     
      generateFp: function() {
        return 'a03f5a4e5ff4427b241b0e37063e67c0'
       },
     
     generateUserId: function() {
       return '5cdca3d814ddee0064a05b17'
     },
     
     env: 'UAT',
     
     onSuccess: function(data){
        // (optional) a callback is called when a user links accounts successfully 
      },
      
      onError: function(data){
        // (optional) a callback is called when a user encountered an API error
      },
      
      onExit: function(data){
        // (optional) a callback is called when a user exits chatbot
      },
    
   };

   (function() {
   
     Synapse.create(configuration);
     
    $('#link-button').on('click', function(e) {
       Synapse.open();
     });
   })();
   
 </script>
 
 <div id="app"></div>

</body>
</html>

What’s Next