サードパーティ Web サイトにポータブル仮想エージェント Web クライアントを追加する

  • リリースバージョン: Xanadu
  • 更新日 2024年08月01日
  • 所要時間:4分
  • サードパーティの Web ページで仮想エージェントのポータブル Web クライアントチャットウィジェットを使用するには、必要なコードを Web ページに追加します。

    始める前に

    このトピックの手順を完了する前に、ポータブル仮想エージェント Web クライアントの構成を行ってください。

    詳細については、 ServiceNow Community サイトの「How to embed Virtual Agent in an external site (外部サイトに仮想エージェントを埋め込む方法)」の記事を確認してください。

    必要なロール:virtual_agent_admin または admin

    手順

    このスクリプト参照をページヘッダーにインポートしてインスタンス化し、外部ページヘッダーに ServiceNow チャットインスタンスを作成します。
    注:
    このスクリプト参照例では、site1.example.com は ServiceNow インスタンスの URL を参照します。
    <script type="module" >
          import ServiceNowChat from "https://site1.example.com/uxasset/externals/now-requestor-chat-popover-app/index.jsdbx?sysparm_substitute=false";
          var chat = new ServiceNowChat({ instance: "https://site1.example.com/", });
        </script>
    ヒント:
    組織でカスタムドメイン名を使用している場合は、ServiceNow ドメイン名ではなくカスタムドメイン名をインスタンスプロパティとして入力して、ブラウザーの結果が複数のブラウザー間で確実に一貫しているようにします。
    構成の例
    const chat = new ServiceNowChat({
    	instance: 'https://site1.example.com',
    	context: {
    		skip_load_history: 1
    	},
    	branding: {
    		bgColor: '#333',
    		primaryColor: '#000',
    		hoverColor: '#EFEFEF',
    		activeColor: '#AAA',
    		openIcon: 'custom-open.svg',
    		closeIcon: 'custom-close.svg',
    		sizeMultiplier: 1.6
    	},
    	offsetX: 50,
    	offsetY: 50,
    	position: 'left',
    	translations: {
    		'Open dialog': 'Open chat',
    		'Open Chat. {0} unread message(s)': 'Click to open',
    		'Close chat.': 'Click to close',
    	},
    });
    JSON 構成スキーマ
    {
        instance: <string> - url to your instance, must be of the same domain (sub-domain)
        context: <object> - sys_parm variables to pass into the iframe
        branding: <object> - branding settings
              bgColor: <rgb|hex> - can take an rgb tuple, ie: '56,56,56' or a 3 or 6 hex color code, ie: #333 or #efefef.  background color of button
       	primaryColor: <rgb|hex> - font color
       	hoverColor: <rgb|hex> - hover background color of button
       	activeColor: <rgb|hex> - click / active background color of button
       	openIcon: <string> - name of the uploaded custom icon in settings
       	closeIcon: <string> - name of the uploaded custom icon in settings
       offsetX: <integer> - distance in pixels the button moves along the x-axis
       offsetY: <integer> - distance in pixels the button moves along the y-axis
       position: <enum: left|right> - position left or right side of screen
       translations: <object> - contains label mappings for translations or label changes
       	'Open dialog': <string> - replacement text for accessibility
       	'Open Chat. {0} unread messages(s)': <string> - replacement text for tooltip
       	'Close chat.': <string> - replacement text for tooltip
    }