ホーム オートメーション プロジェクトで使用する最初のチャットボットを作成しようとしています。
これはばかげているように聞こえるかもしれませんし、おそらくこれは進むべき道ではないかもしれませんが、あなたの意見と、おそらくそれを機能させる方法を知りたいです.
ボットに自分の現在地を尋ねて、現在地を返す Python コードを実行し、それで回答を得られるようにしたいと考えています。
これは私の場所です.py
from pyicloud import PyiCloudService
import googlemaps
import aiml
api_key = "##################3"
gmaps = googlemaps.Client(key= api_key)
api = PyiCloudService('###email####','###password###')
longitude = api.iphone.location()['longitude']
latitude = api.iphone.location()['latitude']
current_location = gmaps.reverse_geocode((latitude, longitude))
street = current_location[0]['address_components'][1]['long_name']
house_number = current_location[0]['address_components'][0]['long_name']
def get_location():
current_location = ('%s,%s' % (street, house_number))
return current_location
これで、これを私のamlファイルに入れる方法がわかりました。
<?xml version="1.0" encoding="UTF-8"?>
<aiml>
<category>
<pattern>WHAT IS MY LOCATION</pattern>
<template>??????</template>
</category>
</aiml>
これが意味をなすことを願っています:)
助けてくれてありがとう!