Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Celebrating as our community reaches 100,000 members! Thank you!
avatar

Introduction:

Here is a small demo how NiFi can let you retrieve Stock quotes on voice commands and respond back with the help of Mac Dictation.

- Here you can view the screen recording session that Demonstrates how it works!

NiFi + Mac Dictation Demo

Prerequisite:

1) Assuming you already have latest version of NiFi [0.5.x or later] downloaded on your Mac.

2) Make sure you have Mac dictation feature, and its working!

Steps:

1) Use GetHttp processor to Retrieve any Stock price from “Google Finance”, you can use the below URL to fetch YAHOO stock price:

http://finance.google.com/finance/info?client=ig&q=YHOO

- Processor Properties would look like:

4148-screen-shot-2016-05-11-at-15728-pm.png

2) Use ReplaceText and EvaluateJsonPath processors to trim json result and extract stock value and variation in stock price today. Use UpdateAttribute processor to save values to attributes.

3) Now you can use a RouteOnAttribute to decide when to trigger mail or/and give voice feedback.

4) Finally Use PutEmail processor for email Alert and/or Use ExecuteStreamCommand for voice feedback using Mac OS X’s “say” command, values can be extracted from attributes.

I am Attaching my flow template, which will help you understand better.

retrieving-real-time-quotes.xml

5) you may dry run the flow to see if it works as expected!

6) Now we have to link Mac Dictation to communicate with NiFi. For that we have to create custom commands in Dictation that fire NiFi API calls to make changes in the GetHttp processor based on the stock requested via voice command. [Now you would be thinking about better Speech recognition software 😉 ]

A Sample API call to update processor based on command would look like [update it with your processor-ids and client-ids]:

curl -i -X PUT -H 'Content-Type: application/json' -d '{"revision":{"version":176,"clientId":"93a9b515-1643-4ccf-8db1-71ef38238ae5"},"processor":{"id":"7f033b6f-e13e-4295-85de-33444aae6c4b","parentGroupId":"02888a59-ee2b-483e-8860-b0fdf948de97","config":{"properties":{"URL":"http://finance.google.com/finance/info?client=ig&q=AAPL","Filename":"APPLE"}}}}' http://localhost:8080/nifi-api/controller/process-groups/02888a59-ee2b-483e-8860-b0fdf948de97/proces...

7) Now you can launch Dictation and try out!!

Thanks,

Jobin George

2,898 Views
Comments

Hey @Jobin George , a very fun flow. You could use different voices for a stock going up or down, check out http://www.techradar.com/us/how-to/computing/apple/terminal-101-making-your-mac-talk-with-say-130564...

Hi @Andrew Grande Thanks!, I actually did that:) in the demo video I had it, but disabled and removed in the flow attached [Kathy will say if its going down based on value "You may want to buy some today" or Alex will say if Its going up," you may want to sell some" ;)] Thanks again!

Version history
Last update:
‎08-17-2019 12:30 PM
Updated by:
Contributors