Reputation: 141
I would like to know if there is any way to activate the webhook for all intents (other than activating it one by one). Thank you!
Upvotes: 4
Views: 499
Reputation: 6800
There is no such functionality as of now, but I had similar problem and this is how I solved it:
usersays
"webhookUsed": false,
to "webhookUsed": true,
Restore from zip
optionUPDATE 1:
Below is the code:
import zipfile
import json
import os
import glob
cwd = os.getcwd()
zip_ref = zipfile.ZipFile(cwd + '/filename.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)
Place the zip file you get from dialogflow in the directory same as where you place above code and run the python program.
After running this code, navigate to directory named zipped
and zip all the contents of the file and follow step 4.
UPDATE 2:
Updated the code to make it compatible to multiple languages Dialogflow agent.
Hope it helps.
Upvotes: 4
Reputation: 141
@sid8491 thank you so much, this worked for me!
I had to make some changes so that it worked correctly. Your answer has been very helpful. This is my final script:
import zipfile
import json
import os
import glob
cwd = os.getcwd()
zip_ref = zipfile.ZipFile(cwd + '/Bill.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, encoding="utf8").read())
json_data['webhookUsed'] = True
with open(file, 'w') as outfile:
json.dump(json_data, outfile)
else:
print("Usersay file", file)
Upvotes: 0
Reputation: 50711
Aside from activating it one by one, or downloading the zip file, setting it one by tone in the JSON, and uploading the results - no.
Upvotes: 1