Best Practice | Using Micro-build and low-code to implement Tencent questionnaire satisfaction survey

After the combination of Tencent Questionnaire and Tencent Cloud Weida, developers can embed the questionnaire capability in the application to launch satisfaction surveys through the Weida platform, and synchronize the results of the questionnaire to Weida for subsequent analysis.

This article will guide you how to add Tencent Questionnaire in the application and how to use the questionnaire WebHook capability to synchronize the data to Weida.

Step 1: Create a Questionnaire

Go to Tencent Questionnaire to create a questionnaire and get the delivery link:

Step 2: Add the questionnaire to the WeChat app

1. In the application that needs to add a questionnaire (currently only PC/H5 applications are supported), add a pop-up window component and a button to open the questionnaire: 2. Add click behavior, select page jump and fill in the delivery link of the questionnaire : 3. Final preview and release the application.

Step 3: View the questionnaire results

After the above steps, users can open and fill in the questionnaire in your app. At an appropriate time, you can stop collecting questionnaires and view the questionnaire analysis in the management background of Tencent Questionnaire:

Questionnaire data is synchronized to the microdata model

Note: Tencent Questionnaire-Team Edition service must be activated for the following abilities.

Tencent Questionnaire - Team Edition supports WebHook capability. When the user submits the questionnaire, the callback can be triggered. We can use this ability to synchronize the questionnaire results to Weizhe in real time. The following describes how to use this ability.

Step 4: Create a Satisfaction Survey Data Model

1. Go to the Data Model page and create a new data model for a single machine . 2. Enter the model configuration page and set the model fields according to the following figure.

Step 5: Provide callback service for questionnaire WebHook

1. In the cloud development environment of Weida, create a cloud function to process callbacks: in the package.json file, we need to fill in the dependencies:

{
  "dependencies": {
    "@cloudbase/weda-scf-sdk": "latest"
  }
}
复制代码

index.js We can follow the example, Tencent questionnaire WebHook callback incoming parameters can be found in

'use strict';

const weda = require("@cloudbase/weda-scf-sdk");

exports.main = async (event, context) => {
    // 这里是腾讯问卷触发回调的数据
    const webhookData = JSON.parse(event.body)

    // 将数据写入数据模型中
    const result = await weda.callModel({
        name: 'mydtc_04y565r', // 数据模型标识
        methodName: 'wedaCreate', // 新增数据方法
        params: {
           /** 在这里传入数据模型新增方法的入参  **/
        }
    })

    return result;
};
复制代码

2. On the Cloud Development Access Services page, click New . 3. Set the access service, click OK to get the access link.

The callback link is: default domain name + trigger path.

Step 6: Configure the callback link in Tencent Questionnaire

1. In the questionnaire settings, click Settings on the right side of WebHook . 2. Go to the Setting WebHook page, and click the New WebHook Configuration Callback link.

After completing the above steps, each time a user submits a questionnaire, the results of the questionnaire will be written into the data model.

Guess you like

Origin juejin.im/post/7084147163202060319