I have been working on a script for a while now, and have had many questions asked. I also rewrote a lot of the code as per some peoples suggestions. Yet, I still have this one question that has been unanswered. Below is the code for a "Siri" like iMessage PA. Basically, when I say commands through iMessage to it, it responds.
I have been trying desperately to make it have a bit more intelligence by having it reply in sentences. You can see in the code, when it asks me "...are you ok?" It should look for either "yes" or "no", but only when the first question as been asked. Yet currently it just reponds with the initial "I am fine sir, are you ok?" and then does nothing after that when I tell it yes or no.
Just to be sure its not the main code I have added a plain "hello world" to see if will respond normally which it does. Below is the code:
using terms from application "Messages"
on message received theMessage from theBuddy for theChat
if theMessage is "hello" then
helloresponse()
end if
if theMessage contains "Are you ok" then
areyouok()
if theMessage is "yes" then
happyResponse()
else
if theMessage is "no" then
unhappyResponse()
end if
end if
end if
if theMessage contains "hello world" then
helloworldresponse()
end if
end message received
end using terms from
on helloresponse()
tell application "Messages"
send "Hey sir!" to buddy "email@1.com" of service "E:email@2.com"
end tell
end helloresponse
on happyResponse()
tell application "Messages"
send "you said yes, yey!" to buddy "email@1.com" of service "E:email@2.com"
end tell
end happyResponse
on unhappyResponce()
tell application "Messages"
send "You said no, thats a shame!" to buddy "email@1.com" of service "E:email@2.com"
end tell
end unhappyResponce
on areyouok()
tell application "Messages"
send "I am fine sir, are you ok?" to buddy "email@1.com" of service "E:email@2.com"
end tell
end areyouok
on helloworldresponse()
tell application "Messages"
send "World replies: Hello." to buddy "email@1.com" of service "E:email@2.com"
end tell
end helloworldresponse
Thanks for any help people can give me!