avafab
avafab

Reputation: 1701

Deploying actions on google webhook on glitch

I want to deploy this example on glitch. I've added package.js and index.js to my glitch project and built successfully.

However, the code is missing a section to listen for HTTPS requests. In most node.js/express webapps, there is code to indicate which paths trigger which functions, but this is missing from the example. Can you explain to me how it should work and why that part is missing from this example?

Upvotes: 0

Views: 338

Answers (2)

Bart
Bart

Reputation: 498

The part that "listens to requests" is

// The Entry point to all our actions
  const actionMap = new Map();
  actionMap.set(ACTION_PRICE, priceHandler);
  actionMap.set(ACTION_TOTAL, totalHandler);
  actionMap.set(ACTION_BLOCK, blockCountHandler);
  actionMap.set(ACTION_MARKET, marketCaptHandler);
  actionMap.set(ACTION_INTERVAL, intervalHandler);

  assistant.handleRequest(actionMap);

where each ACTION is an action(in an intent) in Dialogflow and the handler is the corresponding function in your code.

I'd recommend you take a look at

https://codelabs.developers.google.com/codelabs/assistant-codelab/index.html?index=..%2F..%2Findex#0

If you want a good example of an assistant app, though this uses firebase instead of glitch.

Upvotes: 0

Ido Green
Ido Green

Reputation: 2813

It's not clear what do you mean by "the code is missing a section to listen" as the only main feature of index.js is to listen to requests and return information.

I suggest you check index.js and make sure that you getting requests to your end point on glitch.

Also, it would be helpful if you can share your glitch project over here at SO so we could see what you are doing. Btw, you might want to double check that you have all the packages

I also created this simple example on Glitch - It's returning the current bitcoin price. Feel free to remix it and use the code there for your own action. Good luck!

Upvotes: 2

Related Questions