Web deployment (legacy channel)

Updated at:

The channel deployment feature enables you to quickly integrate your Alibaba Cloud Chatbot into your business. It supports deployment on H5 and PC web pages, and you can use rich content such as cards and templates to enhance the chat homepage. This document shows you how to quickly integrate your chatbot.

Deployment methods

Standalone page deployment: The entire page is a chat window. This method is suitable for mobile users.

Floating widget deployment: Similar to the AI assistant in the lower-right corner of the Alibaba Cloud official website, a chat window appears when a user clicks a button. This method is suitable for PC users.

Standalone page deployment

Preview

2→Click Chat Now to open the consultation page →3

Configuration

image

As shown in the figure, after you configure standalone page deployment, click Deploy and then copy the URL to access the page. If the chat window fails to open after deployment, check whether your network is configured with a proxy.

User logon

By default, guests can access a standalone page deployment without logging on. If your system has an existing logon process, you can call the Get User Logon-Free Token API to obtain a logon-free token. Append this token to the URL, as shown in the following example:

https://chatbot.aliyuncs.com/intl/index.htm?locale=zh-CN&from=xxx&_user_access_token=${Token}

Floating widget deployment

Preview

image

Configuration

image

  1. Floating Button Icon: If you do not set an icon, the default icon is used.

  2. Floating Button Text: If you leave this field empty, no text appears.

  3. Floating page URL (also known as host page URL): Enter the URL of the page where the floating widget will appear. You can add up to 20 URLs.

    1. Enter only the page URL without any parameters. For example, if the product details page URL is https://detail.tmall.com/item.html?id=58335634352721&spm=a1z10.1-b-s.w5003-112312312, enter only https://detail.tmall.com/item.html.

    2. Wildcards are supported. For example: https://*.aliyun.com.

  4. Deployment script: Insert the deployment script into your host website's code. The following code provides an example:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Chat Assistant</title>
    </head>
    <body>
        <!-- Copied deployment script -->
        <script src="https://o.alicdn.com/mecloud/shell/dialog.js"></script>
        <script>
          window.AlimeDialog({
            from: 'xxxxxxxxx'
          });
        </script>
    </body>
    </html>

User logon

By default, guests can access a floating widget deployment without logging on. If your system has an existing logon process, you can call the Get User Logon-Free Token API to obtain a logon-free token. Configure this token in the deployment script, as shown in the following example:

<script src="https://o.alicdn.com/mecloud/shell/dialog.js"></script>
<script>
    window.AlimeDialog({
    from: 'xxxxxxxxx',
    params: { _user_access_token: '${Token}' }
    });
</script>

Platform authorization

WeChat authorization

In the Alibaba Cloud Chatbot console, navigate to Channel Deployment > Web Channel > Service Interface Deployment. On the WeChat H5 management page, click WeChat Authorization Management to view all WeChat authorizations in the current workspace.

image

WeChat Official Account authorization

  1. To associate a WeChat Official Account, click Add WeChat Authorization and follow these steps:

    1. Click Add WeChat Authorization and scan the QR code with your mobile phone to authorize the WeChat Official Account.image

    2. Click Bind to Current Channel.image

  1. Click Deploy. You can then use the link from the standalone page deployment section and configure it in the menu bar or auto-reply settings of your WeChat Official Account.image

WeChat Mini Program authorization

To associate a WeChat Mini Program, click Add WeChat Authorization and follow these steps:

  1. Configure the domain name and download the authorization file. In the WeChat Mini Program, go to Mini Program page > Development Management > Development Settings > Business Domain Name.image

  2. Click Modify next to the domain name and download the verification file.image

    Note

    If you receive the error message "A domain name can be bound to a maximum of 100 mini programs under different entities" when binding in the WeChat Mini Program, change the domain name configuration to "https://chatbot-001.biz.aliyun.com" and replace the domain name in the channel deployment URL that your mini program embeds or redirects to with this new domain name.

  3. Click Add WeChat Authorization and scan the QR code with your mobile phone to authorize the mini program.image

  4. Upload the authorization file

    1. Upload the verification file that you downloaded from the WeChat platform in Step 1. The system automatically generates the domain name.

    2. You must upload an authorization file for a WeChat Mini Program, but not for a WeChat Official Account.

    3. The WeChat Mini Program verifies the authorization file to prevent duplicates. Ensure that the authorization file is not a duplicate.

  5. Bind the associated channel. Click Bind to Current Channel.image

Important
  • If you scan the QR code for a WeChat Official Account or WeChat Mini Program that is already authorized, you will receive a message indicating that it is authorized in another workspace and that you must unbind it first.

  • When you unbind an account, the system automatically deletes its authorization information, associated channels, and related data.

Alipay authorization

In the Alibaba Cloud Chatbot console, navigate to Channel Deployment > Web Channel > Service Interface Deployment. Click Alipay Authorization Management to view all Alipay authorizations in the current workspace.

image

Alipay Mini Program authorization

  1. Click Add Alipay Authorization to add an Alipay authorization to the workspace.

  2. On the Alipay platform, configure the domain name and download the authorization file.imageimage

  3. In the Alibaba Cloud Chatbot console, navigate to Channel Deployment > Web Channel > Service Interface Deployment. Click Alipay Authorization Management to go to the authorization page. Click Add Alipay Mini Program and enter the AppID and account name from the Alipay platform.image

  4. Upload the authorization file. Upload the verification file that you downloaded from the Alipay platform.image

  5. Associate the mini program with the current channel.image

  6. Click Deploy to apply the changes.image

Douyin Mini Program authorization

In the Alibaba Cloud Chatbot console, navigate to Channel Deployment > Web Channel > Service Interface Deployment. Click Douyin Authorization Management to view all Douyin authorizations in the current workspace.

image

Douyin Mini Program authorization

  1. Click Add Douyin Mini Program and enter the Douyin Open Platform account name and the corresponding AppID.image

  2. Upload the authorization file that you downloaded from the Douyin platform.image

  3. Domain name configuration. Set the H5 Domain Name Configuration for the Douyin Mini Program to the value of Domain Name Configuration.image

  4. Configuration path for Douyin: Console > My Apps > Open Mini Program > Mini Program Configuration > Development Configuration > Server Domain Name. Add the configuration in the Valid request domains field.imageimageimage

  5. Associate the Douyin Mini Program with the current channel.image

  6. Click Deploy to apply the changes.image

FAQ

Q: How to bypass security verification?

By default, guests can access the chat window. To prevent malicious traffic or abuse, guests must complete a security verification. To bypass this verification, call the Get User Logon-Free Token API to obtain a token and append it to the URL. This allows users to access the chat without logging on or completing the verification. For example: https://chatbot.aliyuncs.com/intl/index.htm?locale=zh-CN&from=xxx&_user_access_token=${Token}

Q: How long is chat history retained?

For guests, the system generates a temporary token that is valid for 8 hours, after which it automatically clears the chat history. To retain the chat history for a longer period, call the Get User Logon-Free Token API to enable a logged-on state for users. In this case, the chat history is retained permanently.

Q: How to adjust floating widget position?

You cannot configure the position of the floating widget in the console. To adjust its position, add the following code to your floating widget deployment script as needed.

window.AlimeDialog({
  from: 'ptUzpffYsV',
  /** Configure the following parameters as needed. */
  params: {
    _user_access_token: 'xxxxxxxx',
    /** Specify the language, for example, zh-CN or en-US.  */
    locale: 'en-US',
  },

  /** [Optional] The container to which the widget is attached. If provided, the widget's position is calculated to float on one side of the container. */
  container: {
    /* The selector for the container. */
    selector: '#main',
    /* The side of the container to attach to. Valid values: 'left', 'right'. Default: 'right'. */
    align: 'left',
    /* [Optional] The offset relative to the container's position. x is the horizontal offset and y is the vertical offset. Values must be numbers. The unit is pixels (px). */
    offset: {
      x: 10,
      y: 25,
    },
  },
  /*
 // [Optional] The absolute position on the page.
 // Note: This configuration may have compatibility issues between mobile and PC. You can use CSS selectors to directly change the widget's position.
 // Valid properties: 'left', 'right', 'top', 'bottom'.
 // For a fixed position, enter a number. The default unit is px. Example: 12.
 // For a percentage-based position, use the format 'number%'. Example: '12%'.
 // Default values: right: 40, bottom: 50.
 // If both top and bottom are set, top takes precedence.
 // If both left and right are set, left takes precedence. */
  position: {
    bottom: 100 /** pixels */,
    right: '10%',
  },
});

To change the size of the floating widget, you can override its CSS styles. For example, to change the width of the pop-up widget to 800px, use the following code:

#J_xiaomi_dialog .J_Dialog {
    width: 800px !important;
    left: -804px !important;
}

#J_xiaomi_dialog .J_Dialog .alicare-frame {
   width: 800px  !important;
}

Q: How to customize floating widget style?

In the console, you can only change the text and icon of the floating widget. For more advanced customization, you can use one of the following three methods.

  • Method 1: Import the JS file from the floating widget deployment script and use CSS to override the widget's styles on your website. The widget's DOM is located within the #J_xiaomi_dialog .J_weak selector. You can inspect the specific DOM structure in your browser's developer tools.

  • Method 2: Import the JS file from the floating widget deployment script. On your website, use CSS to hide the widget's default DOM element. Then, create your own custom HTML for the widget. Add a click listener to your custom element that calls the provided JavaScript function to launch the widget pop-up. The following code provides an example:

    /** Hide the widget by using CSS */
    #J_xiaomi_dialog .J_weak{display: none;} 
    const dom = document.querySelector('your_widget_selector');
    if (dom) {
      // Add a click listener event
      dom.addEventListener('click', showDialog);
    }
    
    function showDialog() {
      // Use the global variable window.alimeDialog to avoid re-rendering the pop-up
      if (!window.alimeDialog) {
        window.alimeDialog = window.AlimeDialog({
          from: 'xxxx', // Change to the 'from' value in your deployment script
          params: {
            // The token for logon-free access. We recommend that you request the token right before showing the pop-up and do not cache it to avoid expiration.
            _user_access_token: 'xxxx',
            // Language setting
            locale: "zh-CN",
          },
          // Whether to open automatically
          autoOpen: true,
          onRendered: function onRendered(ui) {
            // You can modify the rendering position here
            ui.$container.style.right = '100px';
          },
        });
      } else if (window.alimeDialog.instance && window.alimeDialog.instance.ui) {
        // If the pop-up has already been opened, just show it again
        window.alimeDialog.instance.ui.dialog.show();
      }
    }
    
  • Method 3: Implement your own logic for the widget and the pop-up. In the pop-up, embed the channel deployment H5 page by using an iframe.

Q: WeChat custom menu "Publish failed" error

You must first complete WeChat verification. After verification, your WeChat Official Account can add external links. Without verification, you can only link to content within your own official account.

Q: Is the autocomplete feature supported?

Yes. When a user manually enters a question, the autocomplete feature automatically recommends related questions from the knowledge base. This reduces user input effort and improves the resolution rate.

image

Q: Input box blocked by keyboard in app

For a solution, see the following document: https://zhuanlan.zhihu.com/p/343569217.

Q: Compliance filing for apps using Qwen models

For more information, see Application compliance filing.

Q: How to pass variables during deployment?

All input variables must be prefixed with _biz_ to avoid overwriting built-in system runtime information. If this prefix is not added, the passed parameters will be ignored.

  • Pass a variable in a standalone page deployment

    1. Assume the incoming variable is city=hangzhou.

    2. After you add the prefix, the parameter is: _biz_city=hangzhou. A complete example is: https://chatbot.aliyuncs.com/intl/index.htm?locale=zh-CN&from=xx&_biz_city=hangzhou.

    3. To reference this variable in a flow, use the following expression: ${envVars['VENDOR_PARAM']['_biz_city']}.

  • Pass a variable in a floating widget deployment

    1. Assume the input variable is city: 'hangzhou'.

    2. After the prefix is added, the result is: _biz_city: 'hangzhou'. The following is a complete example:

      <script src="https://o.alicdn.com/mecloud/shell/dialog.js"></script>
      <script>
          window.AlimeDialog({
              from: 'xxxxx',
              params: {
                  _user_access_token: '${Token}',
                  _biz_city: 'hangzhou'
              }
          },
          );
      </script>
    3. To reference this variable in a flow, use the following expression: ${envVars['VENDOR_PARAM']['_biz_city']}.

  • Logged-on user information

    1. After you use the Get User Logon-Free Token API and configure logon-free access as described in User logon, you can retrieve user information from the passthrough parameters.

    2. To reference user information in a flow, use the appropriate variable expression. For example: ${envVars['VENDOR_PARAM']['userInfo']['extraInfo']['customerNameCard'][0]['value']}.

    3. The following fields are available in the user information object:

      {
          "userInfo": {
              // User ID in the Alibaba Cloud Chatbot user system
              "id": 1018397757,
              // The Nick passed in the GenerateUserAccessToken API call
              "nick": "Kelin",
              // The ForeignId passed in the GenerateUserAccessToken API call
              "foreignId": "b01f2f81",
              // The Telephone passed in the GenerateUserAccessToken API call
              "telephone": "1882222****",
              // The Email passed in the GenerateUserAccessToken API call
              "email": "xxx@aliyunid.com",
              // The ExtraInfo passed in the GenerateUserAccessToken API call
              "extraInfo": {
                  "exp": 1221,
                  "city": "hangzhou",
                  "customerNameCard": [
                      {
                          "value": "v2",
                          "key": "Level"
                      }
                  ]
              },
              // User type. 'user' indicates a logged-on user, and 'guest' indicates a guest.
              "userType": "user"
          }
      }