Hello Readers,

Today we’ll talk about how does Siri Answers our query and from where does Siri gets all the information.
Well, Siri uses Many API’s like Google, Yahoo!,  Wikipedia, and others to get all the information it has, and it’s not possible to cover all the API’s Siri uses in a single blog post.

Hence today we’ll learn an interesting API (I think so) known as WolfRam | Alpha API which was utilized quite a times when I asked Siri to look for something.

Examples.

  • Calculations, Mathematics
  • Checking Weather, Route 
  • Current Time in a City

When you ask a question to Siri, it feeds your query to an API and provides you the information on basis of data returned from API call. Like in the below screenshot Siri fulfilled my query using WolfRam | Alpha API,  as you can see there is a small icon in the Right bottom corner of the Second screenshot.

 

I thought of giving this API a try with PowerShell and see if we can make a Pseudo Search Engine ( Kinda! 😉 )  in PowerShell.


HOW IT WORKS :

Making this API fetch data like Siri is a  Five-step process :

  1. Start code Execution: Call the first function of the code in order to start the execution of code 
  2. Create the Windows form: The function called in the previous step Generate a Windows form so that user feed in his query
  3. Create a Listener to listen to Search now Events:  Wait until User feeds his query in TextBox and either hit ENTER or click the Search Button.
  4. Call the WolfRam|Alpha API: Once the Event mentioned in the previous step is triggered call the Wolfram|Alpha API with the user Query, which will return some information based upon the Query.
  5. Display Output: Once information is retrieved from the API, Structure the information like the way Siri presents it on iPhones. Then Display it in the same Windows Form. Below is the structure of my code, for a better understanding of how it works.

1

NOTE:  Please note that in order to understand how it works and the Terms and Attributes I used in my code, I’ll advise you to go through the API documentation Here.

And navigate Here to know the Structure of data API Call returns in a Pictorial representation.


GET THE SCRIPT


HOW TO USE IT :

Run the Script and Type in your query in the TextBox then Hit Enter or click on Search Button, the script will do the rest for you, just like a Search Engine in the below animation.

ezgif.com-gif-maker (4)

Hoping you’ll find this fun.
Happy Reading  🙂

Optical Character Recognition

Author of “PowerShell Guide to Python“, “Windows Subsystem for Linux (WSL)” and currently writing the most awaited book: “PowerShell to C# and Back” !


Subscribe to our mailing list

* indicates required