How to call a web-action from watson assistant dialog node? - ibm-watson

I am trying to call a simple web-action from my dialog node. Both service and cloud space is hosted in London, still I am getting error that "Direct CloudFunctions calls are not supported on this platform".
I have created a simple skill and added 3 nodes to it, 1 is welcome node, second is test node in that I have added action of type web-action and created a webaction on cloud that returns a simple message. Below is the details for test node and action.
{
"output": {
"generic": [
{
"values": [
{
"text": "Hi how are you $message"
}
],
"response_type": "text",
"selection_policy": "sequential"
}
]
},
"actions": [
{
"name": "/namespace_dev/default/Call DB",
"type": "web_action",
"parameters": {
"mob_num": "$MNum"
},
"credentials": "my cloud function creds",
"result_variable": "message"
}
]
}
Below is the web-action code.
function main(params) {
return { message: 'Hello World' };
}
Node when test node is invoked the action should get executed but I am getting below error.
Dialog node error
Direct CloudFunctions calls are not supported on this platform
Can someone please suggest what mistake I am doing?

Currently, as stated in the Actions Docs, the actions are accessible only in Germany and US South. However, this document differs based on the language you read in. In the German Version, which is my default, you might read this:
Gegenwärtig können Sie eine Cloud Functions-Aktion über Watson Assistant-Instanzen aufrufen, die in den Regionen 'Vereinigte Staaten (Süden)' oder 'Deutschland' gehostet werden.
which translates (using Google) to this:
Currently, you can invoke a Cloud Functions action through Watson Assistant instances hosted in the United States (South) or Germany regions.
If I switch to the English Version of the Documentation, this information disappears.

Related

How to Convert PDF to Image using Azure Logic App

I'm trying to use a Logic App to convert a PDF File into an Image (JPG). I did every configuration with this article showed but it's not working. When I send it to API, that returns this error:
Not sure whether this is a fix. I have raised a thread in the Adobe Forum as well
I switched the logic app to code view
I moved the below piece of code
{
"body": "JPEG",
"headers": {
"Content-Disposition": "form-data; name=\"targetFormat\""
}
},
Above :
{
"body": "this ith",
"headers": {
"Content-Disposition": "form-data; name=\"InputFile0\""
}
},
Final Version :
Save it, Don't switch it to designer view. Run the Flow. You will be able to run the flow without the above error.

How to create Alexa Catalog for URL Reference for slots

I've found this example that is using the Catalog URL Reference for populating custom slots in Alexa Skill.
The problem is that I don't know how to populate this catalog.
I was able to create the model catalog using ask cli like this:
ask api create-model-catalog -n catalog_name -d "description"
That produces me the catalogId in the form "catalogId" : "amzn1.ask.interactionModel.catalog.blabla" like the one in the GitHub example in the first link.
The problem is that I don't know how to put the values (for example the ingredients.json in the above example) inside that catalog.
I've tried using
ask api create-model-catalog-version -c catalogId -f ingredients.json
But what I obtain is
Call create-model-catalog-version error.
Error code: 400
{
"message": "Request is not valid.",
"violations": [
{
"message": "'source' field of the request is invalid."
}
]
}
In the documentation, there isn't an example of how to deal with this so I'm stuck at this point.
Thanks for your help
In order to create and use a catalog in your alexa skill, you have to:
Upload the catalog file into a bucket or another public storage endpoint.
After that, you have to specify a JSON file with the following content (eg. catalog.json):
{
"type": "URL",
"url": "[your catalog url]"
}
Use the ask api to create the catalog, as you mentioned, to get your catalog-id:
ask api create-model-catalog --catalog-name "IngredientsCatalog"
--catalog-description "Ingredients"
Create a model catalog version by using the file that contains your catalog URL:
ask api create-model-catalog-version --file .\catalog.json --catalog-id [your catalog-id]
This call will provide a command to track the create version status. Something like:
ask api get-model-catalog-update-status -c [your catalog-id] -u [request id]
If the version has been created successfully, then you can set it on your skill interaction model:
"types": [
{
"name": "Ingredient",
"valueSupplier": {
"type": "CatalogValueSupplier",
"valueCatalog": {
"catalogId": "[your catalog-id]",
"version": "[the desired version number]"
}
}
}
]
I can add a little more here that may be helpful:
In step 1 in the answer above, from my testing the S3 bucket must be public. Also, below is the format of the JSON that you will want to use, including the use of synonyms which is not described in the official Amazon example. Note that you don't have to include an ID as shown in that example.
{
"values": [
{
"name": {
"value": "hair salon",
"synonyms": [
"hairdresser",
"beauty parlor"
]
}
},
{
"name": {
"value": "hospital",
"synonyms": [
"emergency room",
"clinic"
]
}
},
]
}

getting a Firefox plugin to detect and mimic attempts to check for Apple Pay support

Now that Apple's credit card offering is out, I can get 2% cash back on purchases on the web made with Apple Pay. Unfortunately, my browser of choice is Firefox, which doesn't yet support Apple Pay.
I'd like to detect attempts to check for Apple Pay support, so I can alert myself in some way and switch over Safari to complete my purchase. Per Apple's docs, this check is performed via window.ApplePaySession.
So, I've attempted the following in an extension:
manifest.json
{
"manifest_version": 2,
"name": "applepay",
"version": "1.0",
"content_scripts": [
{
"matches": [
"*://*/*"
],
"js": [
"applepay.js"
]
}
]
}
applepay.js
window.ApplePaySession = {
canMakePayments: function () {
console.log('canMakePayments');
return Promise.resolve(true);
},
canMakePaymentsWithActiveCard: function () {
console.log('canMakePaymentsWithActiveCard');
Promise.resolve(true);
},
};
I'm able to console.log(window) in applepay.js and get the whole object, but my changes to the object don't appear to take effect - it's acting like window is read-only. What am I missing?
In Firefox, content scripts (addon written in WebExtensions) don't share the same context as page scripts (website scripts).
In your content script, do something similar to this:
function notify(message) {
console.log("do something");
}
exportFunction(notify, window, {defineAs:'notify'});
After, the page script will see that window.notify exists.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Sharing_objects_with_page_scripts

Use parametrized values with Azure Logic App

I'm working with an Azure LogicApp where the workflow have fixed values. Our DevOps tool is VSTS (Visual Studio Team Services) and because we have multiple environments to handle, I have to do some refactoring (using parametrized values) so in VSTS we'll be able to provide environment-specific values.
Thanks to 2 websites I found on Internet I managed to understand that there are 3 kind of parameters :
To understand my problem, here's my action :
I want to have my string "/work/documents" in a parameter value. So in the "Code view" I managed to use a parameter instead of a hard-coded value :
"triggers": {
"When_a_file_is_added_or_modified": {
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['sftp_1']['connectionId']"
}
},
"method": "get",
"path": "/datasets/default/triggers/onupdatedfile",
"queries": {
"folderId": "#{parameters('pathToRootFolder')}"
}
},
"recurrence": {
"frequency": "Hour",
"interval": 1
}
}
}
And in my parameters.json :
"sftp_1_path_root_folder": {
"value": "/work/documents"
}
Here's the final result in Visual Studio:
Am I missing something ? Why isn't the value displayed in the Designer ? Thank you for your help in advance !
When you are using Logic Apps parameters inside your Logic App definition, they are not resolved at design-time, but at run-time. Thus, you are not supposed to see them in the designer. If you run the workflow, you should be able to see the actual value at run-time.
If you want to resolve those parameters at deployment-time, then you would need to write directly from the ARM template using ARM parameters into the workflow definition. This is possible, but in some cases, it can become a bit more complex. That's why I prefer to make use of Logic Apps parameters as described here.

Client-side fan out data structure

I will implement my fan out model in Google's Firebase, but my question is only theoretical so the answer doesn't need to be in Firebase terms.
I am creating an app that I think should have a data structure similar to Tinder. The idea is only one post shows in your feed at a time; you then accept it or reject it and another one pops up and so on. My question is how exactly to structure the data so that it remains fast when the app scales up.
What I have right now is one node called "Posts" that contains every post that has ever been made. The app then queries for a post which is checked against the user Node of "viewedPosts" so that if the queried post has already been accepted/rejected by the user another one is queried until an unseen one is found. This obviously isn't a great solution because if there are a lot of posts, a query through them will be slow (especially if a lot of them have already been seen and the query has to be repeated multiple times).
I came across this article: The Firebase Blog: Client-side fan-out for data consistency which gave me the idea of creating a node inside each user which is "unseen posts" and every time a new post is uploaded by someone, to put it in the unseen folder for every user. This solves the problem on the side of the viewer, but to upload, one would have to download the list of all users in the app and then write to every single one of them.
So the question is, is there a middle ground between these which I can use to accurately do this?
Thank you.
EDIT:
Someone asked for my data structure:
{
"posts": {
"jkldsahjfkds": {
"title": "Simple Post",
"description": "This is my first post",
"numberOfImages": "2",
"price": "14.99",
"timestamp": "51782345",
"postedBy": "-hjd673bbewi7n",
"name": "Ryan Jacobs"
}
"-nisd7enskwes" : {...}
"-asdjfhk7385i" : {...}
"-sdfh49506ndk" : {...}
}
"users": {
"user1": {
"postsViewed": {
"-nisd7enskwes": 51784645,
"-sdfh49506ndk": 51782329
}
"postsLiked": {
"-sdfh49506ndk": 51782329
}
"userData": {
"name": "Albert Jones",
"bio": "Hi! Jow is everyone doing!?",
"location": "London"
}
}
}
}

Resources