Integrate AppFlow into a WeChat Mini Program
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
-
Log in to the WeChat Official Accounts Platform and open your Mini Program's admin console. In the section, add your custom domain name.
Click Modify to add or edit business domain names. You can add up to 200 business domain names.
-
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-viewThis 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-viewcomponent 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.
-
In the login configuration, select Token Mode.
-
From your Mini Program server, call the Generate Logon Session Token API to obtain a
UserSessionTokenfor passwordless sign-in. In the same API call, pass user information such as user ID, username, and avatar. -
Append
?access_session_token=XXXto theweb-viewURL, whereXXXis the token from the previous step.
-