You can configure fulfillment for your agent from the Fulfillment page. You can build and deploy a webhook using your preferred development environment, or use the inline code editor.
To enable fulfillment from an HTTPS endpoint you have created, follow these steps:
- Toggle ENABLED and include the details of your webhook in the form.
Click SAVE at the bottom of the page to save the configuration.
To enable fulfillment for an intent, toggle Enable webhook call for this intent in the Fulfillment section of the intent and click SAVE.
It's important to secure your webhook to prevent unwanted, potentially malicious calls. Dialogflow supports two mechanisms for authentication:
- Basic authentication with login and password.
- Authentication with additional authentication headers.
If your webhook doesn't require any authentication, leave the authentication fields blank.
Note that your webhook must use HTTPS, and the URL must be publicly accessible.
Create a webhook with the inline editor
For simple webhook testing and implementation, you can use the Cloud Functions for Firebase area of the Fulfillment page. In most cases, the free "Spark" tier of Firebase is all you'll need. Tier limitations and pricing information for the other tiers can be found on the Firebase pricing page.
To enable the inline editor, do the following:
- Click on Fulfillment in the left menu.
Click the switch for Inline Editor.
Some basic, functional code is provided to help you get started.
To deploy your fulfillment, click Deploy under the code editor.
After clicking Deploy, Dialogflow will save your Cloud Function for Firebase and begin the deployment process. When deployment is complete, you'll see a timestamp next to the Deploy button that signifies the last time the function was deployed.
(Optional)The link under the code editor can be used to visit the function's logs in the Firebase console. This is used to debug issues and get information on your function.
Export your code
Once you're ready to move your code out of the Fulfillment page, you can use the Download button to get a .ZIP file of your code in its current state.
Here is a list of things to be aware of when using the inline code editor option:
If you modify your function outside of inline code editor, you can no longer use the editor to modify your Cloud Function for Firebase. Your function will continue to provide fulfillment for your agent, but if you need to make changes, you will need to do so in the Firebase console.
The function must be named "dialogflowFirebaseFulfillment". If you change the name of your function, it will not deploy via Dialogflow. If you want to change the name of your function you can download the code, change the function name, and deploy through Firebase's CLI.
You cannot save or download code modified in the inline editor without first deploying.
The inline editor only supports two files: index.js and package.json (modifying package.json will install any dependencies you specify upon deployment).
Network calls originating from your Cloud Function for Firebase to destinations outside Google's network require billing to be enabled for the underlying Google Cloud or Firebase project.