如何获取sessionId- dialogflow [英] How to get a sessionId- dialogflow

查看:76
本文介绍了如何获取sessionId- dialogflow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从响应对象获取sessionId,但这是一种有效的方法,还是还有其他可能获取会话ID或会话对象?

I am trying to get sessionId from response object but is that an efficient way or are there any other possibilities to get the session Id or sessions object?

例如: request.body.session : projects/coffee-shop/agent/sessions/e6eb1812-9c3f-23fa-b590-f1656ee9a56e

如何获取确切的 ID : e6eb1812-9c3f-23fa-b590-f1656ee9a56e 而不是路径.或如何在 projects/coffee-shop/agent/** sessions **/e6eb1812-9c3f-23fa-b590-f1656ee9a56e

How to get exact ID:e6eb1812-9c3f-23fa-b590-f1656ee9a56e instead of path. or How to get the sessions object in the path projects/coffee-shop/agent/**sessions**/e6eb1812-9c3f-23fa-b590-f1656ee9a56e

推荐答案

是的,您可以从WebhookClient的代理实例中获取会话ID:

Yes, you can grab the session id off the agent instance of WebhookClient:

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {

  const agent = new WebhookClient({ request, response });
  console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
  console.log('Dialogflow Request body: ' + JSON.stringify(request.body));

  function welcome(agent) {
    agent.add(`Welcome to my agent!`);

    let sessionId = agent.session;
  }

  let intentMap = new Map();
  intentMap.set('Default Welcome Intent', welcome);
  agent.handleRequest(intentMap);
  });

这篇关于如何获取sessionId- dialogflow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆