How to Use Pass JavaScript Variables Through Web HTML SnippetAs you learned in our tutorial, [[Tutorials-for-admins/Chat/HowtoUsetheChatWidgetHTMLSnippet | How to Use the Web HTML Snippet]], the web HTML snippet is the code that defines your chat widget's configuration.The snippet contains the formatting and style of your configured chat widget, the path to your chat application, the mobile/web API endpoint, the URL of your contact center, and a path to the chat. You can edit the snippet to pass some standard variables through the chat, such as first_name, last_name, email, and phone_number. It is also possible to pass custom variables through the snippet.In this article, you will learn how to format such custom variables in the snippet.# It looks like this: SERVICE_PATTERN_CHAT_CONFIG = { appId: '94066', apiUrl: 'https://example.brightpattern.com/clientweb/api/v1', tenantUrl: 'five.brightpattern.com', chatPath: 'https://example.brightpattern.com/clientweb/chat-client-v4/' /* // Default customer data, it can be collected on current site's context first_name: '', last_name: '', email: '', phone_number: '' */ };To pass custom variables through the chat, simply replace this:/* // Default customer data, it can be collected on current site's context first_name: '', last_name: '', email: '', phone_number: '' */With the following, where "variable_name" is the name of your variable, and "Value" is the value:parameters:{ variable_name: 'Value', }For example: SERVICE_PATTERN_CHAT_CONFIG = { appId: '70a6624585ef2b0981fed84fcd12d4db', apiUrl: 'https://example.brightpattern.com/clientweb/api/v1', tenantUrl: 'example.brightpattern.com', chatPath: 'https://example.brightpattern.com/clientweb/chat-client-v4/', parameters:{ test_var: 'Hello World', } };'''Note:''' You should use either the default customer data parameters '''or''' your own parameters, but not both. Customer parameters use variable ''$(item.externalChatData)'' to collect all customer data from the pre-chat form. If you include both default and custom parameters, you will have duplicate entries of first_name, last_name, email, and phone_number.For more information, see the ''Scenario Builder Reference Guide'', section [[Scenario-builder-reference-guide/VariablesandExpressions/Variables | Variables]].Once you are done with step 3, paste the snippet into your HTML for use on your webpage.
このスニペットには、設定済みのチャットウィジェットのフォーマットとスタイル、チャットアプリケーションへのパス、モバイル/ Web APIのエンドポイント、コンタクトセンターのURL、チャットへのパスが含まれています。スニペットを編集して、first_name、last_name、email、phone_numberなどの一般的な変数をチャットを介して伝えることができます。スニペットを介してカスタム変数を伝えることもできます。