0
votes

I'm using fulfillment webhooks to store analytics data on my servers, so I need it enabled on every possible intent. So far I've been doing it by manually checking "Enable webhook call for this intent" on every intent. That is kinda dangerous though, as it would be easy to forget doing it on an intent. Is there any global way to have it enabled for all intents?

1

1 Answers

0
votes

There is no direct way to do this, but I have made a python script to do the same.
You need to follow below steps to get it done:

  • Export your agent
    Go to settings of your agent, select Export and Import tab and select Export as zip.
    This will give you zip file of your agent
  • Put the zip file in the same folder where your python script file will be present
  • Run the python script
  • A folder named zipped will be created
  • Go inside that folder and select all the files and folders present in that folder and zip them
  • Restore your agent
    Go to settings of your agent, select Export and Import tab and select Restore from zip, select the zip file which you created in above step.

Python code:

import zipfile
import json
import os
import glob

cwd = os.getcwd()

zip_ref = zipfile.ZipFile(cwd + '/your_agent.zip', 'r')
zip_ref.extractall('zipped')
zip_ref.close()

cwd = cwd + '/zipped/intents'

files = glob.glob(cwd + "/*.json")
for file in files:
    print(file)
    if "usersay" not in file:
        json_data= json.loads(open(file).read())
        json_data['webhookUsed'] = True
        with open(file, 'w') as outfile:
            json.dump(json_data, outfile)
print('Done')

Hope it helps.