AIML to fetch Google search

So I have created or modified various AIML to ty things into InMoov, but this one is giving me trouble.

I made all kinds of tests, but everytime I get something that doesn't work.

#####################################

<topic name="GESTURES">
<category>
        <pattern>ROBOT RESEARCH *</pattern>
        <template>
             <random>
               <li>Launching browser </li>
               <li>Searching for you! </li>
               <li>Looking on the net! </li>
            </random><oob>
            <mrl>
          <service>python</service>
          <method>exec</method>
          <param>inmoovsearch()</param>
          <url> "http://www.google.com/search?q=<star/>"</url>
          </mrl></oob>
        </template>
</category></topic>

######################################

This is my inmoovsearch.py file that goes along.

webgui.startService()
def inmoovsearch():
        BareBonesBrowserLaunch.openURL("https://www.google.fr")

#####################################

I tried to make it all more simple this way, but it doesn't work either:

    <category>
        <pattern>ROBOT RESEARCH *</pattern>
        <template>
             <random>
               <li>Launching browser </li>
               <li>Searching for you! </li>
               <li>Looking on the net! </li>
            </random>
            <system> chrome-browser "http://www.google.com/search?q=<star/>"</system>
        </template>
    </category>

##################################

I am sure there is much more simple ways to do that but...


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bartcam's picture

Try this

<category>
<pattern>YOUTUBE  *</pattern>
<template>Let play
<oob><mrl><service>python</service><method>exec</method>
<param>BareBonesBrowserLaunch.openURL("https://www.youtube.pl/results?search_query=<star/>")</param>
</mrl></oob>    
</template>    
</category>
 
 
it works also on google etc.
bartcam's picture

for google

<category>
<pattern>GOOGLE *</pattern>
<template>ok
<oob><mrl><service>python</service><method>exec</method>
<param>BareBonesBrowserLaunch.openURL("https://www.google.com/search?newwindow=1&safe=off&site=webhp&source=hp&q=<star/>")</param>
</mrl></oob>    
</template>    
</category>
hairygael's picture

Thanks bartcam! When

Thanks bartcam!

When modifying for google I get a 404 error with:

<topic name="GESTURES">
<category>
        <pattern>ROBOT RESEARCH *</pattern>
        <template>
             <random>
               <li>Launching browser </li>
               <li>Searching for you! </li>
               <li>Looking on the net! </li>
            </random><oob>
            <mrl>
          <service>python</service>
          <method>exec</method>
          <param>BareBonesBrowserLaunch.openURL("https://www.google.fr/results?search_query=<star/>")</param>
          </mrl></oob>
        </template>
</category></topic>

bartcam's picture

I check this in new version and work

from org.myrobotlab.net import BareBonesBrowserLaunch <--this to inmoov.py
 
 
BareBonesBrowserLaunch.openURL("https://www.google.com/search?newwindow=1&safe=off&site=webhp&source=hp&q=<star/>") <-- this to aiml file
 
 
hairygael's picture

This line is giving me error

This line is giving me error with the AIML:

newwindow=1&safe=off&site=webhp&source=hp&q

The signs "&" are not okay apparently...??

bartcam's picture

try this in the myrobotlab window

from org.myrobotlab.net import BareBonesBrowserLaunch 
BareBonesBrowserLaunch.openURL("https://www.google.com/search?newwindow=1&safe=off&site=webhp&source=hp&q=lampa")
 
 
without saving it to aiml
hairygael's picture

When running directly in MRL

When running directly in MRL python window it works but not in the AIML

:(

hairygael's picture

(No subject)

bartcam's picture

Yes it does not work

Few days ago it works! Really I chcecked this few days ago

 

kwatters's picture

AIML is XML is similar to HTML

You are absolutely correct,  & is treated special.

As with in HTML,  & needs to be encoded as &amp;

>  needs to be &gt;

< needs to be &lt;

"  needs to be &quot;   

AIML follows XML syntax.  So if it's valid XML, the AIML should parse correctly.

One way to validate is to rename the AIML file to   ".xml"  and open it in Internet explorer  (or other browser)

It will come up and if the file is valid it should render correctly..  If there is a syntax error, you should see most of th efile, but it will have an error message around where the error occurred in the XML syntax.

 

Here's a good page on XML syntax.  In particular look at the "Entity References" section

http://www.w3schools.com/xml/xml_syntax.asp

 

Hope this helps!

hairygael's picture

Thanks Kevin for this

Thanks Kevin for this information!

It's more clear now!

pedro's picture

python    import

python 

 

import webbrowser
def searchGoogle(search):
  search = search.replace(' ', '+')
  webbrowser.open('https://www.google.com/search?gs_ivs=1&q=' + str(search))
  True
  
  
AIML
 
<category><pattern>SEARCH *</pattern><template>.<oob><mrl><service>python</service><method>exec</method><param>searchGoogle("<star/>")</param></mrl></oob></template></category>
<category><pattern>GOOGLE VOICE FOR *</pattern><template>.<oob><mrl><service>python</service><method>exec</method><param>searchGoogle("<star/>")</param></mrl></oob></template></category>
 

 

bartcam's picture

NO NEED TO WRITE NEW DEF!

https://encrypted.google.com/#q=<star/>

works 100%!!! Google has changed something, now works fine even in AIML I have checked this now

hairygael's picture

Thanks Pedro, I will set it

Thanks Pedro,

I will set it up

 

hairygael's picture

Great this is finally

Great this is finally working!

<topic name="GESTURES">
<category>
        <pattern>ROBOT RESEARCH *</pattern>
        <template>
             <random>
               <li>Launching browser </li>
               <li>Searching for you! </li>
               <li>Looking on the net! </li>
            </random><oob>
            <mrl>
          <service>python</service>
          <method>exec</method>
          <param>BareBonesBrowserLaunch.openURL("https://encrypted.google.com/#q=<star/>")</param>
          </mrl></oob>
        </template>
</category></topic>

moz4r's picture

Hi !! Gaël do you know if it

Hi !! Gaël do you know if it is possible to control tabs ? ( exemple to close all newly opended tab exept microphone )

hairygael's picture

Well, the only way I do it,

Well, the only way I do it, is to launch only the browser for ear using the Barebown code.