How can I create a intent based feature in Microsoft Luis from API? - azure-language-understanding

I want to create intent features (not global) for a Microsoft Luis app. To create features, I send the following message to my app by calling the create_list_features (documentation for this call) with the following body :
{
"name": "DaysOfWeek",
"phrases": "monday,tuesday,wednesday,thursday,friday,saturday,sunday",
"isExchangeable": true
}
Unfortunately, in the call, there is no way where I can specify the intent (or intent_id) to assign the feature. Is there any other call that I have to perform for assigning the feature to the intent?

Here's the API reference for adding intent feature relation. You specify the intent ID as a request parameter and provide the feature relation information in the request body.
{
"featureName": "Phraselist1",
"isRequired": false
}

Related

Saving user utterance in a parameter during no match intent on start page

I am trying to implement a search functionality using webhook. I want to save user utterance in a parameter in case user query does not match any intent on start page.
Is there any way to save user utterances in parameter so that it can be used by webhook . Currently no match intent is invoked correctly but utterance does not go to webhook.
You should be able to extract the original user query and pass it as a parameter to your CX agents using webhook.
To do so, you should enable the “Use Webhook” option on the specific route where you want the user query to be extracted. When that route is triggered, you should be able to extract the original user query in your Webhook Request’s query union field. Here are the four possible Webhook Request fields where you can extract the relevant data based on the input type that the user provided:
“text” field - if natural language text was provided as input.
“transcript” field - if natural language speech audio was provided as input.
“trigger_event” field - if an event was provided as input.
“trigger_intent” field - if an intent was provided as input.
The user query that you extracted can then be passed as a parameter to your CX agent by adding it to your WebhookResponse body inside either of the following field:
WebhookResponse.page_info.form_info.parameter_info[]
WebhookResponse.session_info.parameters
Here’s an example webhook response containing a session parameter:
jsonResponse = {
"session_info":
{
"parameters":
{
"parameter_name": "parameter value"
}
}
};
What you can do:
Create an intent (e.g. 'NoMatchUtterance')
Fully label any training frases (this could just be some random phrases) for this intent with the parameter-id no-match-utterance (or something else) of type #sys.any. This will make sure that any reply is caught.
Create a route with this intent, below routes that match any other, preset intents. In the fulfillment of this route, you can now use $session.params.no-match-utterance.
An example from my projects:

Is it possible to map a subscription parameter to an array at the mutation output?

I have a theoretical question. As I know subscription parameters must exist as a field in the returning type of the mutation. This means that the type of parameter must also match the type of the field in the returning object of the mutation. Am I right? Suppose I get an array with channels ids in the mutation response. I only send one channel id as a parameter in the subscription. Is it possible to map a subscription parameter to an array at the mutation output? If the channel id exists in the array (field channelsIds), the subscription must work. Is it possible to write this logic in the scheme itself, or is it technically impossible?
GraphQL schema:
schema {
mutation: Mutation
subscription: Subscription
}
type Mutation {
testMutation(input: TestMutationInput): TestMutationOutput
}
type TestMutationOutput {
channelsIds: [String!]!
userId: String!
userEmail: String
userPhoneNumber: String
}
type Subscription {
watchTestMutation(channelId: String!): TestMutationOutput
#aws_subscribe(mutations: ["testMutation"])
}
If I understand you correctly you want to filter based on if the mutation's returned value is in an array that is passed as an argument to the subscription. Sorry to say that is not possible at this time. Subscription filters only evaluate to true or false and cannot accommodate any logic other than that.
At the end of October 2020, I contacted AWS support for advice on this issue. I think this answer may be useful to someone, so I post their answer.
Please allow me to inform you that the use-case that you have
mentioned in the case is currently not possible via AppSync. I
understand that the lack of the feature may be causing inconvenience.
There is an internal feature request already with the AppSync team to
incorporate this feature and I have added a +1 on your behalf. It is
worth noting, that once this feature request is with the team, it will
be up to the team as to if/when this potential infrastructure feature
is implemented, and because of the limited visibility into the
progress of internal development processes, I won’t be able to provide
an ETA regarding its release. I would request you to keep an eye on
the what's new page or the AWS Blogs as all new feature requests and
enhancements are posted there[1-3].
However we can suggest a couple of workarounds in this case:
Filter the required fields on client side itself after receiving the values on the client-side from AppSync.
If the values to be filtered are very limited we can use a fake mutation made with the help of a resolver mapped to “None” Data
source. In this flow, we would create a lambda function that uses a
DynamoDB stream as the trigger. The Lambda function is triggered
whenever there's an update to the DynamoDB table.

We can then include logic in the Lambda function to filter the
required fields and perform a mutation to AppSync. In AppSync, the
mutation which was called by lambda would configured using a resolver
mapped to a “None” Data source. The None data source type passes the
request mapping template directly to the response mapping template.
And when we subscribe to this mutation, we will directly get the
filtered data from Lambda that was used to call this mutation. Please
refer to [4] for a step-by-step description of this process.
But please note that this workaround is cumbersome and would require a lot of changes if the required field values keep changing. Workaround 1(handling it on the client-side) is usually the preferred way to handle this use-case.
Resources:
[1] https://blogs.amazon.com/
[2] https://aws.amazon.com/new/
[3] https://aws.amazon.com/releasenotes/
[4] https://aws.amazon.com/premiumsupport/knowledge-center/appsync-notify-subscribers-real-time/

Send custom data to MS bot from web-chat directline

I want to send extra custom data from webchat to microsoft bot v4. Let's say by send message event I want to append this data:
"mydata": "123"
to the data being posted and retrieve it in the bot (preferably in the turnContext) and do some logic based on it inside the bot logic.
What is the best way to handle this. Is there any built-in functionality or I should use custom ways like middlewares?
I'm using directline. Thanks in advance.
It is possible to add custom channel data to outgoing activities in Web Chat v4. You can create a custom store middleware to modify activities sent by the user. Channel data is a channel-specific property bag that can be used to send non-standard in-band data. Refer to the Backchannel Piggyback on Outgoing Activities Web Chat Sample for more details.
For example,
Here, I will be making use of the package simple-update-in to update the immutable action objects. Then add the minified js file from unpkg.com to the < head> of the html:
…
<head>
<title>Web Chat: Inject data on post activity</title>
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
+ <script src="https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js"></script>
…
This helps to make use of the middleware to customise DIRECT_LINE/POST_ACTIVITY by updating the action with deep cloning.
…
const store = window.WebChat.createStore(
{},
({ dispatch }) => next => action => {
if (action.type === 'DIRECT_LINE/POST_ACTIVITY') {
+ action = window.simpleUpdateIn(action, ['payload', 'activity', 'channelData', 'email'], () => 'johndoe#example.com');
}
return next(action);
}
);
…
Now all the DIRECT_LINE/POST_ACTIVITY sent on this bot will have an email attached to the channel data. Similarly, you can customize the data you want to send.
Furthermore, as linked in the above answer, you can implement channel-specific functionality by passing the metadata to the channel in the activity object's channel data property.
Hope this helps.
Great question! I think what you're after is the ChannelData field on the Activity sent from WebChat through the channel to your bot.
Some channels have specific enhanced abilities that a bot can be instructed to invoke on the channel by including the appropriate triggers in ChannelData (see the examples in the link for more info on those), but this is also a safe place to send any special data you want to pass to your bot. In general this field exists to pass data from the client to the bot in order to instruct the bot to undertake some custom behavior when processing the message.
In your case it looks like you just need to have the client add some formatted JSON to the ChannelData of out going Activities and add logic to your bot to extract and process it.

beaconinfo.getforobserved always returning an empty response

Here is my request.
POST https://proximitybeacon.googleapis.com/v1beta1/beaconinfo:getforobserved?key=<API_KEY>
with POST data
{
"observations": [
{
"advertisedId": {
"type": "EDDYSTONE",
"id": "XcM0h/AuR31AWAEXxV59Xw=="
},
"timestampMs": "2017-11-28T12:11:23.045123456Z"
}
],
"namespacedTypes": [
"*"
]
}
I've checked the beacon dashboard to see if the beacon has any attachments to it. It has a nearby notification attachment which I want to fetch using this method.
The beaconID in hex is 5dc33487f02e477d40580117c55e7d5f.
I referred to this guide for help but it seems the request they are making is wrong considering the namespacedTypes should be an array and it is a string in the blog.
Here is the documentation for the API.
UPDATE:
If I do a Proximity API list attachment call I get the following result for the same beacon
[
{
"data":"eyJ1cmwiOiAiaHR0cHM6Ly9xLmVkZHkucHJvLzhsMkl3SiIsICJkZXNjcmlwdGlvbiI6ICJTb21lIiwgInRpdGxlIjogIlNvbWUifQ==",
"creationTimeMs":"2017-12-01T18:15:37.418Z",
"attachmentName":"beacons/3!5dc33487f02e477d40580117c55e7d5f/attachments/58dad403-7a99-4085-b338-5fe0b6660abd",
"namespacedType":"com.google.nearby/en"
}
]
Does this mean there is something wrong with the beaconinfo:getforobserved API call?
My understanding is that getforobserved cannot fetch nearby notification attachments but only the attachments defined under the "Attachments" sections in Beacon Dashboard (consisting of a namespace, type and value). The documentation says that getforobserved accepts * to specify all types in all namespaces owned by the client. For nearby notification attachments the namespace is com.google.nearby which is not owned by client. This is my best understanding but I'm not 100% sure about it.
In any case, your getforobserved request looks correct to me. You can verify that the request works correctly by either:
1) Removing the "namespacedTypes" completely from the POST data. In this case the request will not return any attachments but it should return beacon info, so you should get a non-empty answer if the request is otherwise OK.
2) Add an attachment (the other type instead of nearby notification) to the beacon and see if the request returns something. The API will return empty if namespacedTypes is defined but there are no attachments.
Android devices can get nearby notifications automatically if they are enabled on the phone, so typically there should not be need to request the nearby attachments manually. If you want to maintain nearby notification attachments through the API, you can use the other methods provided in the API (such as the list method). If you want to scan for beacons and fetch attachments, I would use the normal attachments which offers more flexibility with the content.

How to notify specific people with yammer REST api

I would like to notify a specific set of people when posting a message with Yammer's REST API. The desired effect should be the same as "Add people to notify" in the native web application:
After some research with the REST API documentation, i found the direct_to_id field in the request data object.
direct_to_id - Send a private message directly to the user indicated.
I'm not sure what this attribute actually does, so I tried the following:
var data = {
"body": "test message",
"group_id": XXXXXX, //a valid group id
"direct_to_id": XXXXXXXXXX, //a valid user id
};
but after I add the "direct_to_id" field to my post, i get a 400 (bad request) error. I also don't know if this method works with notifications to multiple users.
Ok, i figured it out by reverse engineering the yammer embed widget. When posting a message with people to be notified, yammer embed set a "cc" field in the web form, according to fiddler:
In javascript, simply do this:
var data = {
"body": "test message",
"group_id": XXXXXX,
"cc": "[[user:XXXXXX]],[[user:XXXXXX]]",
};
This approach is not documented in Yammer's API so I'm not sure if it will be supported in the future. In the meanwhile, I really wish that Yammer had better documentation. It would save developers lots of time and trouble.

Resources