Intent returning Null for Rasa nlu - rasa-nlu

I am currently running into an issue where if the user types a word that has not been trained in the nlu file, the nlu will return this:
"intent": {
"name": null,
"confidence": 0.0
}
With other scenarios, it works great! Is there a way to capture these errors and have rasa return the default error message? Please let me know. Thank you!

It is unclear how you are using this nlu response.
If you are using it in rasa_core, you can capture & handle any such intent beforehand in your Custom Action Class.
e.g.
def run(self, dispatcher, tracker, domain):
intent = tracker.latest_message.intent["name"]
If you want to do it at rasa_nlu level itself, go to rasa_nlu installation directory (usually it is in "Python install folder"\Lib\site-packages\rasa_nlu\ and make below changes in model.py
def default_output_attributes():
return {"intent": {"name": None, "confidence": 0.0}, "entities": []}
to
def default_output_attributes():
return {"intent": {"name": "YOUR_CUSTOM_NAME", "confidence": 0.0}, "entities": []}
But please be cautioned in using second one. You may have to take care while upgrading rasa_nlu python package.

Related

Is there a way to write an Expression in Power Automate to retrieve item from SurveyMonkey?

There is no dynamic content you can get from the SurveyMonkey trigger in Power Automate except for the Analyze URL, Created Date, and Link. Is it possible I could retrieve the data with an expression so I could add fields to SharePoint or send emails based on answers to questions?
For instance, here is some JSON data for a county multiple choice field, that I would like to know the county so I can have the email sent to the correct person:
{
"id": "753498214",
"answers": [
{
"choice_id": "4963767255",
"simple_text": "Williamson"
}
],
"family": "single_choice",
"subtype": "menu",
"heading": "County where the problem is occurring:"
}
And basically, a way to create dynamic fields from the content so it would be more usable?
I am a novice so your answer will have to assume I know nothing!
Thanks for considering the question.
Overall, anything I have tried is unsuccessful!
I was able to get an answer on Microsoft Power Users support.
Put this data in compose action:
{
"id": "753498214",
"answers": [
{
"choice_id": "4963767255",
"simple_text": "Williamson"
}
],
"family": "single_choice",
"subtype": "menu",
"heading": "County where the problem is occurring:"
}
Then these expressions in additional compose actions:
To get choice_id:
outputs('Compose')?['answers']?[0]?['choice_id']
To get simple_text:
outputs('Compose')?['answers']?[0]?['simple_text']
Reference link here where I retrieved the answer is here.
https://powerusers.microsoft.com/t5/General-Power-Automate/How-to-write-an-expression-to-retrieve-answer/m-p/1960784#M114215

How to add own Parameters and Response values in the drf-yasg library for swagger documentation?

I use the drf-yasg library to generate project documentation for the developer front-ends. I can't figure out how to add my data to the fields Parameters and Responses
For example, this class
class VendorsCreateView(APIView):
"""
:param:
data = {
"vendor_name": "TestName",
"country": "Belarus",
"nda": "2020-12-12",
"parent": "",
"contacts": [{"contact_name": "Mrk", "phone": "2373823", "email": "dRqT#rgmail.com"},
{"contact_name": "Uio", "phone": "34567", "email": "rdq#gmail.com"}
]
}
:return: swagger name
"""
But I don't exactly get what I want
How do I add these parameters?
#swagger_auto_schema decorator is what you are looking for.
Maybe it will help someone who wants extra parameter in GET-request - you should use argument "manual_parameters" in drf-yasg, e.g. field you want to order by to:
order_by = openapi.Parameter('order_by', openapi.IN_QUERY,
description="field you want to order by to",
type=openapi.TYPE_STRING)
#swagger_auto_schema(manual_parameters=[order_by])
def list(self, request, *args, **kwargs):
swagger:

How can I use the regex_features in my trainning data

How can I use regex_features in json format?
I have just started using rasa-nlu. I have installed and ran the demo successfully - it works well. But I have juest tried by common_examples.
{"rasa_nlu_data":{"common_examples":[],"regex_features":[{"name":"zipcode","pattern":"[0-9]{5}"},{"name":"greet","pattern":"hello[^\\s]*"}]}}
Now I want to know how to use regex_features and how does it works. It will be better to have some examples.
Thanks a lot!
Check out the documentation of Rasa here.
The example is
{
"rasa_nlu_data": {
"regex_features": [
{
"name": "zipcode",
"pattern": "[0-9]{5}"
},
{
"name": "greet",
"pattern": "hey[^\\s]*"
},
]
}
}
Also make sure that the RegexFeaturizer component is part of your NLU pipeline. I further suggest to update to Rasa 1.x which contains both Rasa Core and NLU, since rasa_nlu will not longer be maintained as single package. Also the Rasa Forum is a good place for getting help on Rasa.

Is it possible to tell luis to extract an specific value from a given text?

i want to create an chat bot which can track packages (and many things more). I'm kinda new to all these intents and entities things. My goal to achive is that if i say to the chatbot "track the package [PACKAGEID]" or "could you please find [PACKAGEID] for me?" and than luis should return the intent and the [PACKAGEID]. Is this possible? Or if not, is there something else i can use (best would be if this is from microsoft, because of business stuff... yay)
kind regards,
me.... hey!
To achieve your requirement, you can try the following steps:
1)Add a simple entity named PackageID
2)Add a phrase list for PackageID(s)
3)Add a intent named FindPackage and add some example utterances, and then label entity in utterance.
4)Train (and publish) the app
Test result:
Note:
I'm kinda new to all these intents and entities things.
You can get more information about key concepts of LUIS app in LUIS documentation.
If you know all possible formats of the "PACKAGEID" then you may use Entity of type "Regex"
1) click at
2) Create Regex definition. Example below matches all PACKAGEID-s
starting by "KQ" then followed by 8 to 10 numbers, ending by "DE"
3) If you try sentence "could you please find kq123456789de for me?" then you get following result
{
"query": "could you please find kq123456789de for me?",
"topScoringIntent": {
"intent": "Status",
"score": 0.9369452
},
"intents": [
{
"intent": "Status",
"score": 0.9369452
},
...
],
"entities": [
{
"entity": "kq123456789de",
"type": "PACKAGEID",
"startIndex": 22,
"endIndex": 34
}
]
}

Pull public event data from Google Calendar

I may be over thinking this a bit. On my web site, I would like to user certain data from my public google calendar. My plan is to pull it on the server side so I can do things like process it, cache it and format it the way I want.
I've been looking at using the Google Api libraries, but I can't get past any of the authorization hurdles. A service account sounds like what I really want, but I'm having trouble wrapping my head around how that works in this situation.
The old GDATA apis would be ok, but I'm not very keen on using them because they look fairly deprecated at this point by the newer libraries.
Since it is all public data, I'm hoping there is a simpler way to get to the event data that I'm looking for.
In case it matters, my site is Asp.Net (MVC).
Update
Ok, I was definitely way over thinking it. See my answer.
Now that RSS has been removed from Google Calendar, I've been in search of an easy replacement. I dug around and found the following in the Google Calendar API that seems to do the trick: calendar.events.list
Calendar Events List in Google API Explorer is a good place to get started with the different parameters and options - and it'll build you an example request string. You can see that I specified a minimum time of 2/5/2016, sort it by the start time, and show deleted events.
GET https://www.googleapis.com/calendar/v3/calendars/[CALENDAR ID HERE]/events?
orderBy=startTime&showDeleted=true&singleEvents=true&
timeMin=2016-02-05T00%3A00%3A00Z&key={YOUR_API_KEY}
Results are in JSON so you can parse it in your favorite programming language, ASP.NET or whatever. Result looks like:
{
"kind": "calendar#events",
"etag": "\"123456789123456\"",
"summary": "My Public Calendar",
"updated": "2016-01-29T14:38:29.392Z",
"timeZone": "America/New_York",
"accessRole": "reader",
"defaultReminders": [ ],
"items": [ {
"kind": "calendar#event",
"etag": "\"9876543210987654\"",
"id": "sfdljgsdkjgheakrht4sfdjfscd",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=sdgtukhysrih489759sdkjfhwseihty7934hyt94hdorujt3q95uy689u9yhfdgnbiwe5hy",
"created": "2015-07-06T16:21:59.000Z",
"updated": "2015-07-06T16:21:59.329Z",
"summary": "In-Service Day",
"location": "Maui, HI",
"creator": {
"email": "abra#cadabra.com",
"displayName": "Joe Abra"
},
"organizer": {
"email": "cadabra.com_sejhrgtuiwerghwi4hruh#group.calendar.google.com",
"displayName": "My Public Calendar",
"self": true
},
"start": {
"date": "2016-02-08"
},
"end": {
"date": "2016-02-09"
},
"transparency": "transparent",
"iCalUID": "isdt56y784g78ty86tgsfdgh#google.com",
"sequence": 0
},
{
...
}]
}
One good answer to this (the one I'm going with) is to simply use the calendar's public address to get the data. This is an option that I had forgotten about and it works fine for this particular situation.
You can find the url for the data if you go to the settings for a particular calendar and pick the format you want (I went with xml for this situation.)
The data that you get out of this service is very human-reader optimized, but I can make it work for what I'm doing.

Resources