简体   繁体   English

在Google智能助理教程中找不到Firebase webhook的功能网址

[英]Can't find the function url for Firebase webhook in Google Assistant tutorial

I've been doing the Codelabs tutorial on " Facts about You: Build a conversational app for the Google Assistant " but have run into a problem. 我一直在做关于“ 关于你的事实:为Google智能助理构建会话应用程序 ”的Codelabs教程,但遇到了问题。

Page 4 of the tutorial is devoted to using Cloud Functions for Firebase for setting up a webhook to provide custom responses. 本教程的第4页致力于使用Cloud Functions for Firebase来设置webhook以提供自定义响应。 Step 7 on that page says "Once the Cloud Functions is deployed, the Function URL will be printed in the Firebase CLI logs. This URL is separate from the Project Console URL.” 该页面上的步骤7显示“部署云功能后,功能URL将打印在Firebase CLI日志中。此URL与项目控制台URL分开。”

My problem is that I only see the Console URL. 我的问题是我只看到控制台URL。 I don't see a Function URL anywhere. 我没有在任何地方看到功能URL。

Can anyone please clarify where I should find the Function URL? 任何人都可以澄清我应该在哪里找到功能URL? My app won't run properly without knowing the endpoint URL for the webhoook. 如果不知道webhoook的端点URL,我的应用将无法正常运行。

Thanks! 谢谢!

I noticed you included the tag #actions-on-google in your question. 我注意到你在问题中包含了#actions-on-google标签。 I think perhaps Firebase does not print the URL for dialogflowFirebaseFulfillment actions. 我想Firebase可能不打印dialogflowFirebaseFulfillment操作的URL。 But, you can also view your functions' URLs inside the Firebase console. 但是,您还可以在Firebase控制台中查看功能的网址。

If you don't know it already, you can get the console's URL from deploying. 如果您还不知道,可以从部署中获取控制台的URL。 After deploying the console URL will be printed in the output as shown below. 部署控制台后,URL将在输出中打印,如下所示。 Note console URL does not change from deploy to deploy, so you can bookmark it as well. 注意控制台URL不会从部署更改为部署,因此您也可以将其添加为书签。

Project Console: https://console.firebase.google.com/project/goodmorningroutine-ac4b1/overview

Inside the Firebase console go to Functions on the left. 在Firebase控制台内部,转到左侧的“功能”。 That page will show a list of functions each with its request URL as shown below. 该页面将显示一个函数列表,每个函数都有其请求URL,如下所示。

在此输入图像描述

When the codelab instructs you to run firebase deploy --only functions , it will output the URL for the HTTP function that you created. firebase deploy --only functions指示您运行firebase deploy --only functions ,它将输出您创建的HTTP函数的URL。 It will be the last line of output and look something like this: 它将是输出的最后一行,看起来像这样:

Function URL (foo): https://us-central1-my-codelab.cloudfunctions.net/foo

Copy that URL - it's your webhook endpoint. 复制该URL - 这是您的webhook端点。

I was facing the same issue ..... I Just saved the file before deploying 我遇到了同样的问题.....我刚刚在部署之前保存了文件

That easy I hope it works for you 这很容易,我希望它适合你

I ran into the same problem. 我遇到了同样的问题。

It works when I deploy the file from here . 从我这里部署文件时它可以工作。

After comparing with my own file, I realized that missed two lines in failed case: 在与我自己的文件进行比较后,我意识到在失败的情况下错过了两行:

const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

As per the google Firebase docs you need to make sure that you are writing your functions in the index.js file in the functions directory . 根据Google Firebase文档,您需要确保在函数目录index.js文件中编写函数 If you run firebase deploy --only functions the CLI will look at that specific index folder. 如果运行firebase deploy --only functions ,CLI将查看该特定索引文件夹。 If there are no functions specified in the index.js file in the functions directory you will just see "Deploy Complete" and the URL of the Console 如果函数目录中的index.js文件中没有指定函数,您将看到“部署完成”和控制台的URL

Save the index.js file and then run "Firebase deploy --only functions" again. 保存index.js文件,然后再次运行“Firebase deploy --only functions”。 That worked for me so hopefully will work on your side as well. 这对我有用,所以希望也能在你身边发挥作用。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM