getContextProvider

Customer Service 全渠道提供了一套功能,扩展了 Dynamics 365 Customer Service Enterprise 的能力,使组织能够通过数字消息传递渠道与客户即时联系和互动。 访问 Customer Service 全渠道需要额外的许可证。 有关详细信息,请参见 Dynamics 365 Customer Service 定价概述Dynamics 365 Customer Service 定价计划页面。

检索当前设置的自定义上下文提供程序(如果有)。

注释

应在引发 lcw:ready 事件 后调用实时聊天 SDK 方法。 您可以通过在窗口对象上添加自己的事件侦听器来监听此事件。

Syntax

Microsoft.Omnichannel.LiveChatWidget.SDK.getContextProvider();

参数

None

返回值

返回当前设置的自定义上下文提供程序(如果有)。 如果没有注册的自定义上下文提供程序,则返回 null。

Example

window.addEventListener("lcw:ready", function handleLivechatReadyEvent(){
   // Setting the custom context provider
   // Throws error if contextProvider is not a function
   Microsoft.Omnichannel.LiveChatWidget.SDK.setContextProvider(function contextProvider(){
      // Here it is assumed that the corresponding work stream would have context variables with logical name of 'contextKey1', 'contextKey2', 'contextKey3'.
      return {
                 'contextKey1': 'contextValue1', // string value
                 'contextKey2': 12.34, // number value
                 'contextKey3': true // boolean value
      };
   });

   // Retrieves the currently set custom context provider
   // If there is no registered custom context provider, then it returns null
   let registeredContextProvider = Microsoft.Omnichannel.LiveChatWidget.SDK.getContextProvider();
});

-->

实时聊天 SDK 的 JavaScript API 参考