L.Prithviraj Singh
L.Prithviraj Singh

Reputation: 13

how to solve actions on google-Api.ai error

Screenshot 2The one screen shot of this errorissue I am building an app using api.ai , an syllabus app which tells you the syllabus, but when I invoke it with desired parameters like branch and semester I have made each individual intent for it even then I'm getting miss answers sometimes like when asked for sem 4 and branch electronics its showing sem 3 sem 4 or of other branch . I have given sem and branch as required n given few invoking statements even then getting this. Tried even training it manually for free 30s of actions on api.ai no solution please help. Not using any web hook , context , event.

Upvotes: 1

Views: 131

Answers (2)

L.Prithviraj Singh
L.Prithviraj Singh

Reputation: 13

An simple trick would be what i did, just have an entity saved for both branch and semester , use sys.original parameters and an common phrase for provoking each intent saves up the hard work.

Upvotes: 0

user1582859
user1582859

Reputation: 63

Short answer - check here for screenshots http://imgur.com/a/tVBlD

Long answer - You have two options

1) Create 3 separate custom entities for each branch type (computer science, civil, communication) which you need to attach to your branch parameter

2) Using the sys.any entity and attaching it to your branch parameter; then determining what the incoming parameter value is on a server then sending back a response through a webhook.

If you go the second route, you have to create a webhook and hardcode recognized words like 'computer science' in IF statements which check the incoming parameter (sent through JSON from API.AI). This route will be more difficult but I think you will have to travel it regardless because you will have backend architecture which you access to find and return the syllabus.

Note the second route is what I did to solve a similar issue.

You can also use regex to match an item in a list which limits the amount of hardcoding and if statements you have to do.

Python regex search example

        baseurl = "http://mywebsite.com:9001/"  
        # Parse the document 
        # Build the URL + File Path and Parse the Document    
        url = baseurl + 'Data'
        xmlLink = urllib.request.urlopen(url)
        xmlData = etree.parse(xmlLink)
        xmlLink.close()    

        # Find the number of elements to cycle through 
        numberOfElements = xmlData.xpath("count(//myData/data)")
        numberOfElements = int(numberOfElements)
        types = xmlData.xpath("//myData/data")


        # Search the string        
        i = 0
        while numberOfElements > i:
            listSearch= types[i].text

            match = re.search(parameter, listSearch, re.IGNORECASE)

            if match is None:
                i += 1
            else:
                # Grab the ID 
                elementID = types[i].get('id')
                i = 0
                break

Upvotes: 1

Related Questions