Having trouble PUTting profile variables in Watson Dialog service - json

I think this is actually two (related) problems. If I try to set profile variables in the Watson Dialog API via Postman, I don't get any errors (200 return code) but the variables don't get set. This is the data I'm sending:
{
"client_id": 152008,
"name_values":[
{
"name": "second",
"value": "2"
}]
}
and this is the answer I get:
{
"client_id": 152008,
"name_values": []
}
Doing a GET confirms that the variables were not set.
If I try to do it via dialog.updateProfile() in the watson-developer-cloud package using the same JSON, I get
Error: Missing required parameters: name_values
instead.
Has anyone successfully set Watson Dialog profile variables? How did you do it?

The Dialog profile variable you wish to manipulate via the API needs to already exist in the Dialog XML file. You can not create a new Dialog profile variable via the API.

Related

Twilio Autopilot, best method to check mobile number in external database

I would like to use Twilio autopilot to build a whatsapp Chatbot. I need to know if a user has already used our service before. This means that on initiation, i get the data from an external source, i can then use functions to further specify the chatbot logic.
I am wondering what are the best options in the twilio environment to get that external data loaded in event or memory? I see webhooks are only for diagnostics, and i dont know what are the async capabilities of functions. Could someone elaborate a bit about the pro's and cons of different methods?
Thanks
you can take a look at The Autopilot Request. These request parameters are provided to your application (via a webhook associated with a task), where you can add additional logic to see if this is a new user or returning user and return the appropriate Autopilot Actions, one of which is Remember.
An approach would be setting a webhook that will determine if the User has used the system before on to the Assistant's assistant_initiation more info
The webhook can then reply with a JSON Remember + Redirect
Example -
{
"actions": [
{
"remember": {
"isNewuser": "true"
}
},
{
"redirect": "task://newUserTask"
}
]
}
OR
{
"actions": [
{
"remember": {
"isNewuser": "false"
}
},
{
"redirect": "task://oldUserTask"
}
]
}
Also since "isNewuser": "true" will be on the assistant's memory you can use that info on any following task until the session (4 Hours) expires.

Getting all application extensions, and just applicaiton extensions for an object from MS Graph

Assume I know the extension names I am looking for I could get a users extensions like so:
GET https://graph.microsoft.com/v1.0/users/{{OBJECT_ID}}?$select=extension_{{APP_ID_WITHOUT_GUIDS}}_SomeId,extension_{{APP_ID_WITHOUT_GUIDS}}_SomeValue
Or I could get the attributes from his member groups like so:
GET https://graph.microsoft.com/v1.0/users/{{OBJECT_ID}}/memberOf?$select=extension_{{APP_ID_WITHOUT_GUIDS}}_SomeId,extension_{{APP_ID_WITHOUT_GUIDS}}_SomeValue
However, what If I wanted to see all extension the token had paticular access to. $select=extension_* does not work I get the following:
{
"error": {
"code": "BadRequest",
"message": "Term 'extension_*' is not valid in a $select or $expand expression.",
"innerError": {
"request-id": "3b4e14d6-3bbc-429b-8c45-b0fea629f4a6",
"date": "2018-04-06T13:35:40"
}
}
}
Is there syntax to make this possible?
No, this isn't possible with Microsoft Graph (using v1 Directory Schema Extensions). With Azure AD Graph API there is a function - getAvailableExtensionProperties - that should return all the available v1 directory schema extensions available in the tenant; this doesn't exist in Microsoft Graph. If you use Microsoft Graph schema extensions, you can query /schemaExtensions to find all public schema extension definitions available for use in any tenant (although your app also needs to have been granted access to the underlying extended object - like user).
Hope this helps,

How do I access the inner data in this Google Custom Search errors array?

I have a web app using Google Custom Search via REST. So far, everything works fine, but when I exceed the allotted daily quota of queries, I want to give the user some info about it. I get this JSON response, and I can access the "code" and "message" data using response.error.code and response.error.message, but I don´t know how to access the subset "errors", specifically "reason".
I know this is a JSON question, but I don´t have much experience with it.
This is the JSON structure I receive (which is what I expect)
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceeded",
"message": "This API requires billing to be enabled on the project. Visit https://console.developers.google.com/billing?project=323544036192 to enable billing.",
"extendedHelp": "https://console.developers.google.com/billing?project=323544036192"
}
],
"code": 403,
"message": "This API requires billing to be enabled on the project. Visit https://console.developers.google.com/billing?project=323544036192 to enable billing."
}
}
I found the solution trying different things. I think I got lucky.
console.log(response.error.errors[0].reason);
This gives me the data I was trying to access.

Logic App designer removes foreach loop without error or exception

I have a logic app that uses a webhook trigger on a service bus message queue to post selected messages to an API app using a HTTP+Swagger action.
Azure Logic App Designer
Here’s the json array (DBChanges) from the triggerBody that the foreach is supposed to iterate over
"DBChanges":[{"Key":"ItemID","Value":"101"},{"Key":"Description","Value":"Decript the message"},{"Key":"Owner","Value":"Samuel"}]
This is the logic app code for the DBChanges POST. The foreach loop is supposed to iterate over all the elements of the DBChanges array which is a key, value pair in the swagger metadata.
Azure Logic App Code View
When I switch to design mode after adding the foreach loop the designer strips the foreach code out even though it appears syntactically correct.
Does anyone know why the logic app designer strips out the foreach when switching between Design and Code views?
Try update your condition to "expression": "#equals(triggerBody()['Description'], 'Create')",.
Within the condition, you want to have a for-each first, then HTTP action inside it, not the other way around (I'm using Compose as an example, but you can substitute it to HTTP+Swagger in your case), note how I use #item() to reference each value inside the DBChanges array.
"actions": {
"For_each": {
"actions": {
"Compose": {
"inputs": "#item()",
"runAfter": {},
"type": "Compose"
}
},
"foreach": "#triggerBody()['DBChanges']",
"runAfter": {},
"type": "Foreach"
}
}
To help you reference the right value in a JSON blob, we recently added action Parse JSON, you can add it after your HTTP Webhook trigger, provide the body as input, and include a schema of the JSON it will be returning. You will be able to use friendly tokens from the picker instead of having to handcraft them. :)
Hope this helps, feel free to reach out to me at Derek.Li (at) Microsoft dot com.

How can I enable the file upload permission?

I'm trying to upload images generated in my Flash application to an album on Facebook. This was working earlier in the year, but revisiting the code I now get the following OAuthException:
(#324) Requires upload file
I am using the most recent version of the ActionSccript Facebook API. The setup works like this:
First I do the authentication check with PHP to ensure users have granted permission before having to wait for the Flash to load. I'm requesting the publish_stream and user_photos permissions. The access token comes back correctly.
Once the user is authenticated the Flash is loaded and performs its own initialisation, passing fileUpload=true as part of the init object:
var initObject:Object = {
channelUrl : "myChannelURL.html",
fileUpload : true
}
Facebook.init(
'myAppID',
myCallbackFunction,
initObject,
myAccessToken
);
This seems to work as expected, the callback receives the uid of the current user.
At the end of my application I POST a Bitmap object to a predetermined album:
Facebook.api(
albumID+"/photos",
onImagePost,
{
message:"",
image:new Bitmap(myBitmapData),
fileName:''
},
URLRequestMethod.POST
);
At this point Facebook returns a 400 response:
"error": {
"message": "(#324) Requires upload file",
"type": "OAuthException"
}
What more do I need to do to ensure that this permission is being included?
It turns out that this was not a permissions error at all. Since I last deployed this code Facebook have tightened up their restrictions a bit, and the fileName parameter passed as part of the api call can no longer be an empty string. Simply passing any old text as a file name fixes the problem.
Facebook.api(
albumID+"/photos",
onImagePost,
{
message:"",
image:new Bitmap(myBitmapData),
fileName:'FILE' // required to be non-empty
},
URLRequestMethod.POST
);
Im not sure if this is a solution that can be translated into the Actionscript SDK... But, with the PHP SDK there is a method inside the facebook SDK that is called setFileUploadSupport - try looking in the code for a place to set that parameter to true.