小编Hen*_*Hao的帖子

How to use Dialogflow CX API pass parameters to webhook?It seemed that detectIntent() set session queryParams does not work

According to the google dialogflow cx document: https://cloud.google.com/dialogflow/cx/docs/concept/parameter https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/QueryParameters

单击以显示参考 我知道我们可以使用 api 来设置会话参数。所以我想通过API方式将参数传递给webhook。

步骤1:前端,使用Detectintent() API,填写queryParams项。
步骤2:GoogleDialogflowCX服务器将设置参数作为会话参数。
第三步:Webhook接收google端的函数调用。我们可以从http请求中找到所有的session参数。

就我而言,我只能接收 DialogFlow Agent 中设置的变量,但没有收到通过 detectorintent() API 设置的任何参数。我想我一定做错了什么,谁能告诉我该怎么办?谢谢。

我的代码如下(Nodejs代码):

  const sessionPath = client.projectLocationAgentSessionPath(
    projectId,
    location,
    agentId,
    sessionId
  );
 
  var mapParameters = new Map([['Michael', 95], ['Bob', 75], ['Tracy', 85]]);
 
 const request = {
    session: sessionPath,
    
    "queryInput": {
      
      "text": {
        "text": query,
      },
      languageCode,
    },

    'queryParams': {
      'timeZone': 'America/Los_Angeles',
      'parameters': {
        "fields":mapParameters
      }
    },

 };
const [response] = await client.detectIntent(request);
Run Code Online (Sandbox Code Playgroud)

dialogflow-es dialogflow-cx

3
推荐指数
1
解决办法
3678
查看次数

标签 统计

dialogflow-cx ×1

dialogflow-es ×1