Dialogflow Integration¶
There are two methods for integrating Advertising.chat with a Dialogflow-based chatbot. Which method you should use depends primarily on whether you are already using your own Webhook for Dialogflow Fulfillment.
If you are not using your own Webhook for Dialogflow fulfillment, you can add offers from Advertising.chat with some simple configuration changes shown in the Integration with no existing webhook section below.
If you are currently using a Webhook for Dialogflow fulfillment, you will need to modify your existing webhook configuration to enable offers from Advertising.chat. Follow the instructions below for Integration with existing webhook.
Integration with no existing webhook¶
If your Dialogflow project does not already use Webhooks for Fulfillment, integration with Advertising.chat can be done with some simple configuration changes.
- In the Dialogflow console, select
Fulfillmentfrom the menu bar - Verify that both "Webhook" and "Inline Editor" sliders are Disabled. If either is Enabled, you'll want to use the instructions at Integration with existing webhook to integrate Advertising.chat.
- Enable the "Webhook" option and configure the URL and HEADERS fields to have these values:
| field | value | |
|---|---|---|
| URL | https://webhooks.advertising.chat/dialogflow | |
| HEADERS | direqt-api-key | <your API key> |
Note
You can get your API key from the Advertising.chat Console.
Integration with existing webhook¶
If you are already using a webhook for fulfillment, you can still use the Advertising.chat webhook from within Dialogflow. You simply provide the Advertising.chat webhook with the URL of your existing webhook, and it takes care of invoking your existing webhook as expected.
- In the Dialogflow console, select
Fulfillmentfrom the menu bar - Verify that the "Webhook" slider is ENABLED. If the Webhook slider is not ENABLED, you'll want to use the instructions above.
- Note the value of URL, which refers to your existing fulfillment webhook. You're going to be adding that to the direqt-fulfillment-webhook header below.
- Configure the URL and HEADERS fields to have these values:
| field | value | |
|---|---|---|
| URL | https://webhooks.advertising.chat/dialogflow | |
| HEADERS | direqt-api-key | <your API key> |
| HEADERS | direqt-fulfillment-webhook | <your existing webhook URL> |
If you have any BASIC AUTH or other HEADERS that are used by your existing webhook, leave them in place.
Note
You can get your API key from the Advertising.chat Console.
Adding an Offer to an Intent¶
Advertising.chat offers can be dynamically inserted any time an Intent you have defined is triggered. When you configure an Intent to include an offer, the default behavior is to send the offer, if any, after the Intent has sent its own response. So you shouldn't have to modify your intent at all to accommodate an offer; the user's conversation flow will remain the same whether or not an offer is served.
- Select the Intent from the Dialogflow Intents menu.
- Scroll to the bottom and enable "Enable webhook call for this intent."
- In the "Actions and parameters" section, set "action" to a unique value. This value is used by Advertising.chat to determine the Moment for the offer.
If your Intent already has an action value, that's fine: this is the same value that you'll want to set up in the Advertising.chat Console to recognize the specific moment. For example, the Default Welcome Intent has an action value of "input.welcome", so by default, Advertising.chat will look for a Moment with code of "input.welcome" when asked to serve an offer at that point.
Note
You may have to tap "Add Parameters and Action" to see the Action setting.
Test it out¶
Your Dialogflow agent is now configured to deliver dynamic offers to your subscribers. To test it out, use the "Try it now" function in the Dialogflow console to invoke your Intent. When your integration is successful, you'll see the offer delivered after the Intent's own response.
Behavior with respect to existing responses¶
When Advertising.chat is configured to return an offer for an Intent, and the Intent already has a configured response, then the offer from Advertising.chat (if any) will be sent after the Intent's response.
In the special case where the Intent's response is a carousel or card, then the user will see a carousel containing both the Intent's content as well as the Advertising.chat offer.