Best practice | using micro build low code to realize Tencent questionnaire satisfaction survey

Time:2022-5-18

After the Tencent questionnaire is combined with Tencent cloud micro build, developers can embed the questionnaire ability in the application through the micro build platform to launch the satisfaction survey, and synchronize the results of the questionnaire to micro build for subsequent analysis.

This article will guide you how to add Tencent questionnaire to your application and how to use the questionnaire webhook capability to synchronize data to wechat.

Step 1: create a questionnaire

go toTencent questionnaireCreate a questionnaire and get the launch link:

Step 2: add the questionnaire to the micro build application

1. In the applications that need to add a questionnaire (currently only PC / H5 applications are supported), add the pop-up component and the button to open the questionnaire:

2. AddWhen clickedBehavior, choicePage JumpAnd fill in the delivery link of the questionnaire:

3. Finally preview and publish the application.

Step 3: view the questionnaire results

After the above steps, users can open and fill in the questionnaire in your application. At the right time, you can stop collecting the questionnaire and view the questionnaire analysis in the background of Tencent questionnaire management:

The questionnaire data is synchronized to the micro data model

Note: Tencent questionnaire team service must be enabled for the following abilities.

Tencent questionnaire – team versionSupport webhook capabilities. When a user submits a questionnaire, a callback can be triggered. We can use this ability to synchronize the questionnaire results to wechat in real time. How to use this capability is described below.

Step 4: create a satisfaction survey data model

1. Enterdata modelPage, stand-aloneNew data model
2. EnterModel configurationPage, set the model fields according to the following figure.

Step 5: provide callback service for questionnaire webhook

1. In the cloud development environment of wechat, create aCloud functionTo handle callbacks:

Including package JSON file we need to fill in the dependency:

{
  "dependencies": {
    "@cloudbase/weda-scf-sdk": "latest"
  }
}

index. JS we can follow the example. For the incoming parameters of Tencent questionnaire webhook callback, see

'use strict';

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

exports.main = async (event, context) => {
    //Here is the data of Tencent questionnaire trigger callback
    const webhookData = JSON.parse(event.body)

    //Write data to data model
    const result = await weda.callModel({
        name: 'mydtc_ 04y565r ', // data model ID
        Methodname: 'wedcreate1', // add a data method
        params: {
           /**Here, the input parameters of the new method of the data model are passed in**/
        }
    })

    return result;
};

2. Enter cloud developmentAccess servicesPage, clicknewly build

3. To set up access services, clickconfirmGet the access link after.

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

Step 6: configure callback link in Tencent questionnaire

1. In the setting of the questionnaire, click the button on the right side of webhookset up

2. EnterSet up webhookPage, clickNew webhookConfigure the callback link.

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