1

This question is already asked but that is not solve my issue, am new in this.

Am creating Google Actions Builder and I try to connect my local code with help of webhook. I have followed this steps Steps I followed.

My code:

const { conversation } = require('@assistant/conversation');
const functions = require('firebase-functions');

const app = conversation();

app.handle('startAmo', conv => {
    console.log('abc');
  // Implement your code here
  conv.add("welcome to start Amx");
});

exports.ActionsOnGoogleFulfillment = functions.https.onRequest(app);

But while I accessing ngrok URL it shows Not found message

enter image description here

In local it is showing this error message

enter image description here

My action builder handler:

enter image description here

I have added ngrok URL in webhook section enter image description here

Please help me how to use action builder with my localcode handler.

Ramesh S
  • 585
  • 3
  • 10
  • 32

1 Answers1

1

In Cloud Functions for Firebase, the path of the endpoint at your URL is based on the name you have exported. In your case, this was ActionsOnGoogleFulfillment. You would add this to the end of the URL that you get from ngrok.

Using the examples you gave, the HTTPS endpoint that you should enter in the webhook section of the Action Builder console would be:

https://3337-103-224-35-105.in.ngrok.io/ActionsOnGoogleFulfillment

You get tantalizingly close in a few of your attempts, but let's look at why they're not correct.

In this example, you tried using the name of the handler as the path of the url:

enter image description here

This didn't work because the handler name isn't passed as the path. It is sent in some JSON that is POSTed to that URL.

You got even closer when you tested using localhost and calling your function locally:

enter image description here

This did call your function! But since you didn't send a valid JSON body using POST, it didn't know the name of the handler to use, so your handler function didn't get called.

To be clear - the handler name is sent in the body of the POST request as part of a JSON request format. You can't just add the handler name to the end of the URL - there is a lot of other information that is passed in the JSON body. Fortunately, you can use the ngrok inspector to both look at what is being sent from Action Builder if you want to copy and modify it, or to resend a request.

As a final note, however, please be aware that conversational actions, such as those built with Actions Builder, will be shut down on June 13th 2023.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Hi greate Thanks for your answer. Actully I have change my URL endpoint like this `https://7ce4-2409-4072-6d05-d9d-23b3-66c3-8bc1-8efe.in.ngrok.io/ActionsOnGoogleFulfillment/startAmx`. Here `startAmx` is my handler name. And I have check postman there also showing this message `https://im.ge/i/FFRLMa`. But same error it is not showing the result – Ramesh S Jul 19 '22 at 11:29
  • If am wrong please tell me what URL I need to use – Ramesh S Jul 19 '22 at 11:36
  • I've added another paragraph to my answer to clarify. You're both right and wrong. The handler name isn't part of the URL, it needs to be part of the JSON body. You are getting the error because you're not providing the correct body. The best way to test is to use the Action Builder with the URL as I indicated at the top of my answer. – Prisoner Jul 19 '22 at 11:39
  • If I used `https://7ce4-2409-4072-6d05-d9d-23b3-66c3-8bc1-8efe.in.ngrok.io/startAmo` I get the response in the `simulator`. This is my code https://im.ge/i/FFplg4. I have two doubts if i create one more handler how can I write code. – Ramesh S Jul 19 '22 at 12:22
  • Actually am tying to use `Google Action Builder` with `node js` is possible please provide me any guide or courses. I have upvote your answer – Ramesh S Jul 19 '22 at 12:23
  • What are the questions you have at this point? Your URL that ends in `startAmo` is still different than the route you're expecting in your code, which is `startAmx`. As I noted, you can also use the [ngrok inspector](https://ngrok.com/docs/secure-tunnels#inspecting-requests) to see what the request body looks like. – Prisoner Jul 19 '22 at 12:53
  • 1
    Yes, it is possible to use Action Builder with node.js, at least until June 13th 2023. StackOverflow is not usually a good place to get suggestions for guides or courses, although there are several out there on YouTube and elsewhere, including the [codelabs](https://developers.google.com/assistant/conversational/codelabs) and [samples](https://developers.google.com/assistant/conversational/samples) provided by Google at https://developers.google.com/assistant/conversational – Prisoner Jul 19 '22 at 12:56
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/246582/discussion-between-ramesh-s-and-prisoner). – Ramesh S Jul 19 '22 at 13:28
  • I have one doubt in my `node js` code I want to send response to my action builder. For example in simulator `Talk to My App` my code will through `Greetings! Welcome to Test App` like that it will said. So for this please provide me a code I have used this `app.post('/startAmo', (req, res)=>{ console.log(JSON.stringify(req.body, 2, ' ')); res.send({}); })` – Ramesh S Jul 19 '22 at 13:31
  • It sounds like this is a different question than what you initially asked, which was about webhook URLs. I would suggest you start another StackOverflow question with as many details as possible. – Prisoner Jul 19 '22 at 14:50
  • if possible please check this question https://stackoverflow.com/questions/73061679/google-action-builder-account-linking-with-custom-authentication-in-node-js – Ramesh S Jul 21 '22 at 06:40
  • Prisoner: I added `https://3337-103-224-35-105.in.ngrok.io/ActionsOnGoogleFulfillment` in webhook it is working fine. But I have one more doubt. For account linking (https://i.ibb.co/M12TH4P/image.png) `Authorization` and `Token` URL what should we need to add? – Ramesh S Jul 26 '22 at 06:45