通过dialogflow代理从Google Cloud Datastore读取数据

问题描述

我是chatbot域中的新手。我需要开发一个dialogflow聊天机器人,该机器人可以将从用户收集的数据存储到Google Cloud Datastore实体(不是Firebase实时数据库),并在用户搜索时将其取回。

我可以将从用户收集的数据写入数据存储。但是我正在努力检索数据。我正在用dialogflow内联编辑器编写函数

写入功能

 PASS  src/stackoverflow/63570675/index.test.ts
  63570675
    ✓ should pass (5ms)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |      100 |      100 |      100 |      100 |                   |
 index.ts |      100 |      100 |      100 |      100 |                   |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 1 passed,1 total
Tests:       1 passed,1 total
Snapshots:   0 total
Time:        5.292s,estimated 14s

其中“ order_item”是存储数据的种类(数据存储区中的表)。正在成功存储数据。

读取数据:(该功能不起作用)

  function order_pizza(agent) {
     var pizza_size = agent.parameters.size;
     var pizza_topping = agent.parameters.pizza_topping;
     var date_time = agent.parameters.size;
     const taskKey = datastore.key('order_item');
     const entity = {
       key: taskKey,data: {
       item_name: 'pizza',topping: pizza_topping,date_time: date_time,order_time: new Date().toLocaleString(),size: pizza_size }
      };
     return datastore.save(entity).then(() => {
               console.log(`Saved ${entity.key.name}: ${entity.data.item_name}`);
               agent.add(`Your order for ${pizza_topping} pizza has been placed!`);

            });
}

这是我到目前为止尝试过的!无论我在哪里搜索,都可以找到Firebase实时数据库的结果。但找不到Google数据存储区的解决方案! 遵循了许多教程。但是不能完全正确!请帮助!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)