简体   繁体   English

使用任何服务器数据库执行Google Assistant操作

[英]Use of any server database for google assistant actions

I am using google assistant for creating my own actions and i am new to it. 我正在使用Google Assistant创建自己的操作,因此我是新手。 I want to use my own database and save user response to database.Can anyone help me on this please? 我想使用自己的数据库并保存用户对数据库的响应。有人可以帮我吗?

Good morning, Gautam! 早上好,乔塔姆! Your exact fulfillment code will vary depending on which database and cloud environment you choose. 您的确切实现代码将取决于您选择的数据库和云环境。 In my case, I built an action for the Google Assistant that creates an entry in a GCP Cloud Firestore NoSQL database. 就我而言,我为Google助手构建了一个动作 ,该动作在GCP Cloud Firestore NoSQL数据库中创建了一个条目。

This sample code creates an entry in my database: 此示例代码在我的数据库中创建一个条目:

app.intent('write to the wall', (conv) => {
    console.log(conv);
    console.log(conv.input.raw);
    var userReply = conv.input.raw;

    function writeToDb(userReply){

        const dialogflowAgentRef = db.collection('dialogflow').doc('agent');

        return db.runTransaction(t => {
          t.set(dialogflowAgentRef, {entry: userReply});
          conv.ask('The wall now reads, ' + userReply + '\n\n');
          conv.close("Thanks for visiting!");
          return Promise.resolve('Write complete');
        }).then(doc => {
          console.log(`Wrote "${userReply}" to the Firestore database.`);
        }).catch(err => {
          console.log(`Error writing to Firestore: ${err}`);
        //   console.log(`Failed to write "${userReply}" to the Firestore database.`);
        });
    }

    return writeToDb(userReply);

});

Your database create function might look slightly different, but hopefully that helps you get started... provided you choose to use the tech stack introduced in Actions on Google's codelabs : Node.js, Dialogflow, and Firebase 您的数据库create功能可能看起来略有不同,但是希望可以帮助您入门...只要您选择使用Google的代码实验室Actions中引入的技术堆栈:Node.js,Dialogflow和Firebase

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Microsoft SQL Server Migration Assistant for Access 将 Access 数据库转换为 MSSQL 数据库 - Converting Access Database to MSSQL Database Using Microsoft SQL Server Migration Assistant for Access Oracle DB Upgrade Assistant是否可以将10g服务器上的数据库升级到11g服务器 - Will Oracle DB Upgrade assistant work to upgrade database on 10g server to 11g server Sql Server Migration Assistant使用哪种数据库作为内部数据存储库? - What kind of database the Sql Server Migration Assistant uses as an internal data repository? 在数据库中使用rowid有任何不利之处吗? - Is there any disadvantage to use rowid in database? 您可以使用Microsoft SQL Server Management Studio Express管理Google Cloud SQL数据库实例吗? - Can you use Microsoft SQL Server Management Studio Express to manage a Google Cloud SQL database instance? 谷歌使用什么数据库? - What database does Google use? MySQL连接到服务器没有任何数据库 - Mysql connect to server without any database 如何根据不断变化的数据库扩展 AI 助手 - How to scale an AI assistant in regards to a changing database 如何使用 wordpress 数据库到 Laravel? 有什么办法吗? - how to use wordpress database to laravel? is there any way? 类似数据库的操作,无需使用任何数据库 - Database-like operations without any database use
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM