头图

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 supports PC/H5 applications), 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. 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 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 handle 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 Service page, click New .

3. Set the access service, click OK to get the access link.

?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.

CloudBase云开发
425 声望438 粉丝

云开发(Tencent CloudBase,TCB)是云端一体化的后端云服务 ,采用 serverless 架构,免去了移动应用构建中繁琐的服务器搭建和运维。同时云开发提供的静态托管、命令行工具(CLI)、Flutter SDK 等能力极大的降...