Integrate AppFlow into a WeChat Mini Program

Updated at:

This topic explains how to integrate AppFlow into a WeChat Mini Program.

Create an AI assistant page integration

To create the AI assistant, see Create an AI Assistant.

Configure the business domain for the Mini Program

  1. Log in to the WeChat Official Accounts Platform and open your Mini Program's admin console. In the Development > Development Management > Development Settings > Business Domain Name section, add your custom domain name.

    Click Modify to add or edit business domain names. You can add up to 200 business domain names.

  2. After you add the domain name, download the verification file. Configure the business domain name by following the same procedure used for trusted domain names, as described in Step 1: Set a trusted domain name. In the Configure Business Domain Name dialog box, click Download Verification File and place the file in the root directory of your domain. Ensure the file is accessible through a web browser. Then, enter your custom domain name in the input box below. The domain name must have an ICP filing. Newly filed domains can be configured only after 24 hours.

Integrate with a WeChat Mini Program

  • Option 1: Embed using web-view

    This option is less secure because it allows anonymous access. For production environments, use the Integrate with Mini Program login status approach.

    See web-view | WeChat Open Documentation for details on using the web-view component. In your Mini Program, use the web-view component to embed the page URL you obtained. The following is sample code:

     <web-view 
          src="{{url}}" 
        ></web-view>
  • Option 2: Integrate with Mini Program login state

    This option verifies user identity by using a valid token. Use this option for scenarios that require resource protection and support stateless authentication.

    1. In the login configuration, select Token Mode.

    2. From your Mini Program server, call the Generate Logon Session Token API to obtain a UserSessionToken for passwordless sign-in. In the same API call, pass user information such as user ID, username, and avatar.

    3. Append ?access_session_token=XXX to the web-view URL, where XXX is the token from the previous step.