Skip to content

Instantly share code, notes, and snippets.

@lfmundim
Last active October 22, 2018 23:09
Show Gist options
  • Save lfmundim/109bc95bc0c63bda4bc79c93d87cf966 to your computer and use it in GitHub Desktop.
Save lfmundim/109bc95bc0c63bda4bc79c93d87cf966 to your computer and use it in GitHub Desktop.
HTML Script to send user basic data to BLiP

How to send info from a script to the bot using HTML

Base script:

    <div id="chat"></div>

    <script src="https://unpkg.com/blip-chat-widget@1.3.*" type="text/javascript">
    </script>
    <script>
      (function () {
            window.onload = function () {
                var client = new BlipChat();
	    
                client
                .withAppKey('<Bot_App_Key>')
                .withAuth({
                    authType: BlipChat.DEV_AUTH,
                    userIdentity: '<Unique_User_Identifier>',
                    userPassword: '<Unique_User_Password>',
                })
                .withAccount({
			fullName: 'John Doe',
			email:'johndoe@gmail.com',
			phoneNumber: '+15055034455',
			city: 'Decatur',
			extras: {
				'Registro':'01',
				'Instagram': '@fulano'
                                // whatever else you need
			}
		})
		.withButton({"color":"#2CC3D5"})
                .withTarget("chat")
                .build(); 
            }
        })();
    </script>
  • Bot_App_Key is the bot's unique AppKey. It can be found on:

      https://portal.blip.ai/#/application/detail/<BotIdentifier>/channels/blipchat2.0
    

    in the 'Setup' tab

  • Unique_User_Identifier is the identity of the user regarding the chatbot. Usually a combination of the user's type and some unique number identifying them, such as CPF or account registration number in the application

  • Unique_User_Password is the user's password to authenticate with BLiP's chat. Once it is set for the first time, it must be used in any other attempts to open the chat, or else the chat will not load.

  • All of the withAccount parameters are all optional, but enrich the user's contact information for analysis and help-desk assistance

  • The extras parameter is a special kind of account parameter, where you can place any kind of useful information you might need in JSON format. They will be stored in the contact.extras field and are seen by the bot and help-desks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment