腾讯问卷与腾讯云微搭联合后,开发者通过微搭平台即可在应用中嵌入问卷能力进行满意度调查的投放,并将问卷的结果同步至微搭,以便后续进行分析。
本文将指导您如何在应用中加入腾讯问卷,并如何使用问卷 WebHook 能力将数据同步至微搭。
![](https://qcloudimg.tencent-cloud.cn/image/document/1bb63d5af97d8a91c2a752d22769731f.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/1bb63d5af97d8a91c2a752d22769731f.png)
步骤1:创建问卷
![](https://qcloudimg.tencent-cloud.cn/image/document/c0eb531b9cb4c0103ac0d208af2e28ae.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/c0eb531b9cb4c0103ac0d208af2e28ae.png)
步骤2:将问卷加入微搭应用中
1. 在需要添加问卷的应用中(目前暂时只支持 PC/H5 应用),加入弹窗组件及打开问卷的按钮:
![](https://qcloudimg.tencent-cloud.cn/image/document/101197c629f83c1f6b2fa938a318b768.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/101197c629f83c1f6b2fa938a318b768.png)
2. 新增点击时行为,选择页面跳转并将问卷的投放链接填入:
![](https://qcloudimg.tencent-cloud.cn/image/document/78b7368001bcba0854e91fcb0597c963.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/78b7368001bcba0854e91fcb0597c963.png)
3. 最终预览并发布应用即可。
步骤3:查看问卷结果
经过上述步骤,用户已经可以在您的应用中,打开并填报问卷了。在合适的时间,您可以停止收集问卷,并在腾讯问卷的管理后台,查看问卷分析:
![](https://qcloudimg.tencent-cloud.cn/image/document/d15a63a28e155eeb89d158525739a2af.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/d15a63a28e155eeb89d158525739a2af.png)
问卷数据同步至微搭数据模型
注意:
以下能力必须开通腾讯问卷-团队版服务。
腾讯问卷 - 团队版支持 WebHook 能力。当用户提交问卷时,可以触发回调。我们可以利用此能力将问卷结果实时同步到微搭。下面将介绍如何使用此能力。
步骤4:创建满意度调查数据模型
1. 进入 数据模型 页面,单击新建数据模型。
2. 进入模型配置页面,按照下图设置模型字段。
![](https://qcloudimg.tencent-cloud.cn/image/document/a956f6381138daa6d2583f6cda5275af.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/a956f6381138daa6d2583f6cda5275af.png)
步骤5:为问卷 WebHook 提供回调服务
1. 在微搭的云开发环境中,创建一个 云函数,用来处理回调:
![](https://qcloudimg.tencent-cloud.cn/image/document/090d8428f09ad62d303c5d8ba106d7d5.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/090d8428f09ad62d303c5d8ba106d7d5.png)
其中 package.json 文件我们需要填写依赖:
![](https://qcloudimg.tencent-cloud.cn/image/document/5778e94a9ea937583c818ce8b76b10af.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/5778e94a9ea937583c818ce8b76b10af.png)
{"dependencies": {"@cloudbase/weda-scf-sdk": "latest"}}
'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. 进入云开发 访问服务 页面中,单击新建。
![](https://qcloudimg.tencent-cloud.cn/image/document/713481ab3169718c20f868d92dac1393.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/713481ab3169718c20f868d92dac1393.png)
3. 设置访问服务,单击确认后获取访问链接。
![](https://qcloudimg.tencent-cloud.cn/image/document/e3d0a319da4b9739ff4586f22a307ad4.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/e3d0a319da4b9739ff4586f22a307ad4.png)
说明:
回调链接为:默认域名+触发路径。
步骤6:在腾讯问卷配置回调链接
1. 在问卷的设置中,单击 WebHook 右侧的设置。
![](https://qcloudimg.tencent-cloud.cn/image/document/e04f12227e70bcc761cc5bfc7fe26d0a.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/e04f12227e70bcc761cc5bfc7fe26d0a.png)
2. 进入设置 WebHook 页面,单击新建 WebHook 配置回调链接即可。
![](https://qcloudimg.tencent-cloud.cn/image/document/0f5f8f0dcf1448cea22d8f3da2c68237.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/0f5f8f0dcf1448cea22d8f3da2c68237.png)
说明:
完成上述步骤,即可在每次用户提交问卷时,问卷结果都会写入数据模型。