Dialogflow: Programmatically set Fulfillment URL, Google Assistant Integration Settings - actions-on-google

I am working on automating the deployment of my agent, but I'm having trouble doing some steps programmatically.
Dialogflow Fulfillment URL
I was able to get Export/Restore to work using the Dialogflow Enterprise API: https://cloud.google.com/dialogflow-enterprise/docs/reference/rest/v2beta1/projects.agent/export and https://cloud.google.com/dialogflow-enterprise/docs/reference/rest/v2beta1/projects.agent/restore with the agentContent.
But, since the agentContent is an encoded string, there is no way to replace the Fulfillment URL before restoring. Is there a way to update the Fulfillment URL via API?
Dialogflow Google Assistant Integration Settings
Same question with the Google Assistant Integration Settings. Because this is part of the Dialogflow console, I see this as part of the agent. Ideally, we can programmatically create all parts of the agent. Is this available or on the roadmap?
Google Actions: Action Discovery and Update
Lastly, there is the Action Discovery and Update section of the Google Actions console, where we enable intents for push or daily updates. Is there a way to programmatically do this as well?
Thanks.

There is no way to update the fulfilment URL through the API.

agent_content is indeed an encoded byte string of the zip file. But it's possible to programmatically generate the byte string after editing the contents of the export before zipping it.
Here's a python code snippet that may help:-
with open("skeleton_bot/agent.json", "r") as jsonFile:
data = json.load(jsonFile)
data['webhook']['url'] = "https://yoururl.com"
with open("skeleton_bot/agent.json", "w") as jsonFile:
json.dump(data, jsonFile)
shutil.make_archive('skeleton_bot', 'zip', 'skeleton_bot')
with open("../config/skeleton_bot.zip", 'rb') as file_data:
agent_content = file_data.read()
You can then use this byte string to import/restore to dialogflow

Related

Actions On Google NodeJS v2 alpha: isRequestFromDialogflow function moved?

I'm trying to migrate my cloud function from v1 to v2 (nodejs alpha), the command 'app.isRequestFromDialogflow()' no longer works, was this replaced with another function in the alpha version?
Error I'm getting:
TypeError: app.isRequestFromDialogflow is not a function
Do we no longer need to verify that the source of webhook requests is Dialogflow?
Edit: https://dialogflow.com/docs/reference/v2-auth-setup Ok, so it's handled automatically in v2?
Cheers.
Update
Now that the v2 library has been released, the verification property API is stable and now throws a 403 status by default but is customizable. The reference docs for the verification field are here.
Original Answer
In the v2 alpha (which functionality can change based on feedback), this is currently implemented with the verification property in the options object when creating the cross conversational app instance by calling the dialogflow function.
Here's an example:
const app = dialogflow({
verification: {
HEADER_KEY: 'HEADER_VALUE',
},
})
The verification property accepts a JavaScript object with the keys being the Header keys and the values being the Header values to verify it comes from Dialogflow which you had set in the Dialogflow Console Webhook Fulfillment page.
The page you linked is about authentication for the general Dialogflow v2 API, not the webhook fulfillment. That's for if you want to get or manipulate the configured intents and entities in Dialogflow itself not to fulfill a user request.

How do I play an audio file when using Fulfillment with Dialogflow

I'm making a Google Assistant action, similar to what Google does when you say "Play an E note".
I've managed to get my nodejs app to reply back the parameter, but now I need to pass an audio file. How do I do that?
The typical way to do this is to place the audio file on a hosting service somewhere (Firebase Hosting is a good choice, particularly if you're also using Firebase Cloud Functions for your Action, but any place that can serve a file via HTTPS works) and then send back SSML as your response that includes the audio.
This might look something like this:
var audioUrl = 'https://example.com/audiofile.mp3';
var msg = `<speak><audio src="${audioUrl}"></audio></speak>`
app.tell( msg );
Adjust this for your own audio file, and you might want to use app.ask() instead of tell if you are prompting the user to reply to your audio.

Actions on Google not passing parameters

I'm using Dialogflow (previously API.ai) to create an Actions on Google app.
Using Dialogflow I have set up a custom Entity to highlight single words from multiple Intents.
ie. mashable, recode, bbc sport are all words picked up as Entities.
The fulfilment sends a post webhook to an api I created.
When using Dialogflow it sends off
"parameters": {
"news-agent": "BBC Sport"
},
Which is fine, I set up API to detect the parameter and when using Actions on Google simulator
"parameters": {
"news-agent": ""
},
The parameter is blank, I don't see anything in the documentation about why this is happening.
Could someone help?
It's possible that Actions on Google is not picking up a value for the "news-agent" slot.
Try making the "news-agent" slot required in Dialogflow and define a re-prompt question for it.
That way, the event won't be sent to your app unless the "news-agent" slot is filled.

IFTTT recipe api - is there documentation to create recipe using API call

I have already created triggers and actions for IFTTT channel. Now I want to create a recipe using these triggers and actions, but I want to do it not through Maker, but using an API call. What would be the format of the API call (behind Maker UI) to create a recipe, I am seems to unable to see any documentation or examples?
Click the URL in your maker settings to see IFTTT's description, which reads as follows, and shows your individual API key which must be used in your code:
To trigger an Event Make a POST or GET web request to:
https://maker.ifttt.com/trigger/{event}/with/key/tIpcUAlqRkf8Mls9XepGN
With an optional JSON body of:
{ "value1" : "", "value2" : "", "value3" : "" }
The data is completely optional, and you can also
pass value1, value2, and value3 as query parameters or form variables.
This content will be passed on to the Action in your Recipe. You can
also try it with curl from a command line.
curl -X POST https://maker.ifttt.com/trigger/{event}/with/key/tIpcUAlqRkf8Mls9XepGN
Yes. There is a documentation for create / triggers and actions.
You need to create the API from your server like that:
http://api.test.com:8080/ifttt/v1/triggers/{{triggers}}
More information:
Login: https://developers.ifttt.com/channels/t4/triggers
Click triggers in left menu
Create trigger name
Then as the endpoint you need to give your api url.
There is no public API. With old-type call there is internal API you can see REST calls like create/api/state whilst building a recipe, yet it might be protected from use by third party and I did not check the traffic of new applet maker platform. Note, if you are a partner you can embed your recipes into your apps. Upper tier customers are allowed to request new features (such as API or templates).
I was looking for the same, but after wasting hours, NO LUCK. So, I have decided to create one. This might be too late, but here's one repo of IFTTT boilerplate (https://github.com/Dipen-Dedania/ifttt-boilerplate) using NodeJS and express to create your own recipe (custom triggers and actions)

Azure Blob storage REST Api - How to write headers as string

I am new to REST and I am trying to test a REST call to my Private azure blob storage. I downloaded a small REST call testing program that asks for a URL and Headers (both as string).
I need to list all the blobs in a container using the method described here: List Blobs (REST API)
I am basically wondering how to write the Headers (to include my Key to access the private container).
Thanks
Edit : The program I use to test REST calls is an Extension for Chrome named "Simple REST Client"
I think you should input it this way into that chrome plugin:
Authorization="SharedKey accountname:SharedKey" x-ms-date:2013-01-24T21:33:40 (Current Date)
At least according to this document:
http://msdn.microsoft.com/en-us/library/windowsazure/dd179428.aspx