Disclosure : Some of the links in this post are affiliate links so if you click on the link and purchase the item, I will receive a commission.

How to Turn on the Webhook for a Specific Intent Using the Python Client

I was recently trying to set up a DialogFlow intent via the client api and needed to turn on the webhook. Luckily, it turned out to be pretty simple for once.

Assuming you already have your webhook setup for your agent in general, and your code to create DialogFlow intents, you just need to add:


webhook_state = 'WEBHOOK_STATE_ENABLED'

to the Intent you will pass in to your create_intent call (or your update_intent call).

It turns it into:


intent = dialogflow.types.Intent(
  display_name = f"user_tag.{tag.slug}",
  training_phrases = training_phrases,
  messages = messages,
  webhook_state = 'WEBHOOK_STATE_ENABLED'
)
response = intents_client.create_intent(parent, intent)

Your options are:

"WEBHOOK_STATE_ENABLED" - which is turned on

"WEBHOOK_STATE_UNSPECIFIED" - which is turned off...no idea why this isn't called 'disabled'

"WEBHOOK_STATE_ENABLED_FOR_SLOT_FILLING" - which enables the webhook and also calls it during every step of the slot filling process.

Other How to Build a Chatbot Articles

placeholder image