After the combination of Tencent Questionnaire and Tencent Cloud Wechat platform, developers can embed the questionnaire ability into the application for the delivery of satisfaction survey through the wechat platform, and synchronize the results of the questionnaire to wechat for subsequent analysis.
This article will guide you on how to add Tencent questionnaire to your application and how to use the questionnaire WebHook capability to synchronize data to micropartner.
Step 1: Create a questionnaire
To travel toTencent questionnaireCreate a questionnaire and get the drop link:
Step 2: Add the questionnaire to the microlap application
1. In the application that needs to add a questionnaire (currently only PC/H5 application is supported), add the popup component and the button to open the questionnaire:2, newClick on theBehavior, choicePage jumpAnd fill in the delivery link of the questionnaire:3. Preview and release your app.
Step 3: Check the questionnaire results
After the above steps, users can open and fill in the questionnaire in your application. At an appropriate time, you can stop collecting questionnaires and view the questionnaire analysis in the management background of Tencent Questionnaire:
The questionnaire data was synchronized to the microlap data model
Note: The following capabilities must be open to Tencent Questionnaire – Team edition service.
Tencent questionnaire – team version support WebHook ability. When a user submits a questionnaire, a callback can be triggered. We can take advantage of this ability to synchronize the questionnaire results in real time to microbuild. Here’s how to use this capability.
Step 4: Create a satisfaction survey data model
1, enter theThe data modelPage, single machineCreating a New data Model. 2, enterThe model configurationSet the model field according to the following figure.
Step 5: Provide callback service for the questionnaire WebHook
1. In a micro-built cloud development environment, create oneCloud functionTo handle callbacks:Where package.json file we need to fill in dependencies:
{
"dependencies": {
"@cloudbase/weda-scf-sdk": "latest"
}
}
Copy the code
Index.js we can follow the example, Tencent questionnaire WebHook callback incoming parameters can be seen
'use strict'; const weda = require("@cloudbase/weda-scf-sdk"); exports.main = async (event, Const webhookData = json.parse (event.body) // Write data to data model const result = await Weda. callModel({name: 'mydtc_04y565r', // data model id: 'wedaCreate', // add data method params: {/** pass in the input parameter of the new data model method **/}}) return result; };Copy the code
2. Enter cloud developmentAccess the serviceOn the page, clicknew.3. Set the access service and clickconfirmGet the access link after.
The callback link is: default domain name + trigger path.
Step 6: Configure the callback link in Tencent questionnaire
1. In the questionnaire setting, click on the right of WebHookSet up the.2, enterSet the WebHookPage, clickNew WebHookConfigure the callback link.
After completing the above steps, the results of the questionnaire will be written into the data model every time the user submits the questionnaire.