この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

Open CTI を使用した サンプル HTML ページ

この例では、Open CTI を使用して CTI 機能を Salesforce ユーザインターフェースに追加する方法を示します。Salesforce 組織にコールセンター定義ファイルをすでにインポートしたことを前提としています。

  1. HTML ページを作成します。
  2. 次のサンプルコードを切り取って HTML ページに貼り付けます。

    このコードは、Open CTI の各種関数を示しています。

    1swfobject.registerObject("clippy.codeblock-0", "9");<html>
    2<head>
    3      <!-- Imports Open CTI JavaScript library. It should point to a valid Salesforce domain. -->
    4      <script src="https://domain:port/support/api/25.0/interaction.js"></script>
    5      <script type="text/javascript">
    6             // Callback of API method: isInConsole
    7             var isInConsoleCallback = function (response) {
    8                  // Returns true if method is executed in Salesforce console, false otherwise.
    9                  if (response.result) {
    10                      alert('SoftPhone is in Salesforce console.');
    11                  } else {
    12                      alert('SoftPhone is not in Salesforce console.');
    13                  }
    14              };
    15              // Invokes API method: isInConsole
    16              function isInConsole() {
    17                       sforce.interaction.isInConsole(isInConsoleCallback);
    18              }
    19              // Callback of API method: getCallCenterSettings
    20              var getCallCenterSettingsCallback = function (response) {
    21                     // Result returns call center settings as a JSON string.
    22                     if (response.result) {
    23                            alert(response.result);
    24                     } else {
    25                            alert('Error retrieving call center settings ' + response.error);
    26                     }
    27               };
    28               // Invokes API method: getCallCenterSettings
    29               function getCallCenterSettings() {
    30                        sforce.interaction.cti.getCallCenterSettings(getCallCenterSettingsCallback);
    31               }
    32               // Callback of API method: setSoftphoneHeight
    33               var setSoftphoneHeightCallback = function (response) {
    34                        // Returns true if SoftPhone height was set successfully, false otherwise.
    35               if (response.result) {
    36                       alert('Setting SoftPhone height to 300px was successful.');
    37               } else {
    38                      alert('Setting softphone height failed.');
    39               }
    40               };
    41               // Invokes setSoftphoneHeight API method.
    42               function setSoftphoneHeight() {
    43                       sforce.interaction.cti.setSoftphoneHeight(300, setSoftphoneHeightCallback);
    44               }
    45               // Callback of API method: getPageInfo
    46               var getPageInfoCallback = function (response) {
    47                      if (response.result) {
    48                             alert(response.result);
    49                      } else {
    50                             alert('Error occured while trying to get page info: ' + response.error);
    51                      }
    52               }
    53               // Invokes API method getPageInfo
    54               function getPageInfo() {
    55                       sforce.interaction.getPageInfo(getPageInfoCallback);
    56               }
    57      </script>
    58</head>
    59<body>
    60      <button onclick="isInConsole();">isInConsole</button></br>
    61      <button onclick="getCallCenterSettings();">getCallCenterSettings</button></br>
    62      <button onclick="setSoftphoneHeight();">setSoftphoneHeight(300)</button></br>
    63      <button onclick="getPageInfo();">getPageInfo</button>
    64</body>
    65</html>
    66
上記の HTML ページを作成して URL をコールセンター定義ファイルに追加した後に、ソフトフォンが Salesforce の左側または Salesforce コンソールにカスタムコンソールコンポーネントとして表示されます。
Salesforce でのサンプル HTML ページの出力
Salesforce でのソフトフォンとしてのサンプル HTML ページの出力
Salesforce コンソールでのサンプル HTML ページの出力
Service Cloud コンソールでのソフトフォンとしてのサンプル HTML ページの出力