0

I am using Dialogflow Inline Editor for some of my agent intents. There are only two files right there (package.json & index.js). If I want to add a response to a new intent, I just write a function with a response string and match this function with an intent name. Pretty simple.

Now, I want to switch from Inline Editor to my own Webhook. I know I have to run something like Express server on my local machine. However, is this a matter of just copying and pasting the content of these two files into my own two files? Or do I need to do something else to make it work.

Moreover, If I do have some complex fulfillment functions within my Inline Editor (interacting with Google Calendar API), how do I pass credentials if I just copy and paste existing code to a local file?

1 Answers1

0

Basically, if you want to migrate from serverless function to a server Yes, you will have to copy those files and start your own express server

For the server to be webhook, just simply provide a service that can serve POST endpoint for your fulfillment

  1. Create your Node.js project
  2. Install express, dialogflow-fulfillment lib, and other dependencies
  3. Create your POST endpoint for fulfillment
  4. Put the link to that endpoint in Dialogflow

Webhook is just a simple HTTP callback. Dialogflow will trigger the webhook, POST endpoint you provided and after the code execution it will send a response back to the Dialogflow

Webhook Flow

To attach to Dialogflow webhook you'll just need to provide your webhook endpoint that's serve

By replacing the URL* part with your endpoint e.g. https://yourdomain.com/endpointforwebhook

Fullfillment page

If you develop from your local machine try using Ngrok and add a temporary endpoint for the Dialogflow

If for staging or production you'll need a real domain for endpoint simply start from deploying your express server to Heroku and add an endpoint for the Dialogflow

For the credentials part in your local files
You can manage your credentials in the local file with environment env or some configuration management. See Dotenv npm package