Jump to content


Photo

Dial with your iPhone from Alfred [updated to v1.41a]

iphone workflow dial phone prowl

  • Please log in to reply
37 replies to this topic

#1 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 368 posts
  • LocationAuckland, New Zealand

Posted 14 January 2013 - 09:58 AM

Nothing terribly complex here, but I think it's pretty awesome we can do this sort of thing with Alfred:

 

Download here (or go to my webpage for Alfred 1 version)

 

Requires Prowl on your iPhone in order to receive the notifications and launch the dialling process.

 

I'm assuming this could easily be modified to work with Android phones as well, but you'll probably have to wait for Boxcar or Prowl to release Android clients. Pushover might do it, but if it's as lame as the iPhone version, it won't auto-handle the "tel://" URL scheme.

 

Love to know if it works okay for others.

 

----

 

 

13 April 2014: Updated to v1.41a

  • Fixed — inadvertently made incompatible with current public release of Alfred.

 

12 April 2014: Updated to v1.41

  • Bugfix — wasn’t creating storage directory for API key if not already present.

 

3 April 2014: Updated to v1.4

  • Removed Applescript GUI for API key input. Now just uses Alfred interface.
  • Separate keywords in Workflow config.
  • New icons (iOS 7 based).

 

25 March 2013: Updated to v1.3

  • Bug fix: hyphen “-” character was still causing invalid number error.
  • Typos

20 March 2013: Updated to v1.2

  • GUI for user to enter API key rather than having to edit the code
  • Documentation
  • Better handling of other punctuation characters that might be in a valid phone number (including parentheses, *, # and ;).

Edited by CarlosNZ, 13 April 2014 - 08:06 AM.

  • sphardy likes this
Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#2 jarhead

jarhead

    Member

  • Member
  • PipPip
  • 45 posts
  • LocationNashville, TN

Posted 14 January 2013 - 03:40 PM

Pushover is a much better service/app than Prowl. It integrates with IFTTT and has sound notifications not to mention twitter support. Just put tel:// in front of your {query} and it will work with Pushover.

 

UPDATE: I just tested sending just a phone number (6155551212) and it worked correctly in Pushover for iOS.

 

po_phone.png

 

po_call.png



#3 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 368 posts
  • LocationAuckland, New Zealand

Posted 14 January 2013 - 08:38 PM

I couldn't get Pushover to automatically launch the url (ie auto-dial). I had to wait for all the notifications to load, click the latest notification to reveal the link, then click that link, whereas with Prowl, as soon as I open the notification - boom, we're dialling. Pushover may be better in some ways, but Prowl seems to be much better set up for actual acting on the information it gets.


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#4 hankydysplasia

hankydysplasia

    Member

  • Member
  • PipPip
  • 23 posts
  • LocationIllinois

Posted 16 January 2013 - 03:19 AM

Thank you so much!  Works flawlessly - I've tested the hotkey from selected text, the contact call, and the keyword.


  • CarlosNZ likes this

#5 sphardy

sphardy

    Member

  • Member
  • PipPip
  • 81 posts

Posted 23 January 2013 - 10:21 AM

Thanks for a great workflow.

 

One improvement if I may: When validating the phone number you remove all non-digits from the number and then pass that stripped number to Prowl with the URL tel://$phoneno

 

Note however + is a valid symbol and used often to store international numbers. Personally I store all numbers with an international prefix  so they are accessible from wherever I might be. Stripping the + character causes such numbers to fail dialling

 

I've implemented a hack where I reset $phoneno as:

 

phoneno=${arg//[-. ]/} 

 

after the validity check - but I'm sure there's a more elegant way you could implement this

 

/sphardy



#6 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 368 posts
  • LocationAuckland, New Zealand

Posted 23 January 2013 - 11:28 AM

Thanks for a great workflow.

 

One improvement if I may: When validating the phone number you remove all non-digits from the number and then pass that stripped number to Prowl with the URL tel://$phoneno

 

Note however + is a valid symbol and used often to store international numbers. Personally I store all numbers with an international prefix  so they are accessible from wherever I might be. Stripping the + character causes such numbers to fail dialling

 

I've implemented a hack where I reset $phoneno as:

 

phoneno=${arg//[-. ]/} 

 

after the validity check - but I'm sure there's a more elegant way you could implement this

 

/sphardy

Thanks for pointing that out. In my testing, I had thought that removing the + didn't matter, as the numbers I tried worked without it. However, I now realise that they only worked because the number matched existing contacts in my iPhone address book, so the iPhone was smart enough to call it anyway. But I just tried it with a number I don't have stored, and sure enough, it failed.

 

I'll update the workflow to fix that.

 

Cheers.


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#7 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 368 posts
  • LocationAuckland, New Zealand

Posted 23 January 2013 - 12:13 PM

Okay, it's updated now. Let me know if it's behaving properly for you.  :)


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#8 sphardy

sphardy

    Member

  • Member
  • PipPip
  • 81 posts

Posted 23 January 2013 - 12:36 PM

Perfect - and more elegant than my hack

 

Many thanks



#9 BrianGilbert_

BrianGilbert_

    Member

  • Member
  • PipPip
  • 25 posts
  • LocationMelbourne, Australia

Posted 27 January 2013 - 04:36 AM

Hey CarlosNZ, what do I need to set in Prowl so that the call happens without any interation on the phone?

 

At the moment I have to open prowl and click the received message...



#10 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 368 posts
  • LocationAuckland, New Zealand

Posted 27 January 2013 - 05:31 AM

Hey CarlosNZ, what do I need to set in Prowl so that the call happens without any interation on the phone?

 

At the moment I have to open prowl and click the received message...

photo27011362145pm.jpg

 

Just make sure that one's off. ;)


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#11 BrianGilbert_

BrianGilbert_

    Member

  • Member
  • PipPip
  • 25 posts
  • LocationMelbourne, Australia

Posted 27 January 2013 - 06:06 AM

photo27011362145pm.jpg

 

Just make sure that one's off. ;)

I have that off, but I still have to open prowl for any received message before the call happens, is that what you get?



#12 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 368 posts
  • LocationAuckland, New Zealand

Posted 27 January 2013 - 06:18 AM

I have that off, but I still have to open prowl for any received message and click it before the call happens, is that what you get?

Actually, no. That's odd, because you shouldn't have to do anything. It should be automatically responding to the custom URL scheme, "tel://". That setting I mentioned before should only be the difference between asking or not asking to auto-launch the phone app. I've never had to actually click the notification. In fact, that's the main reason I chose Prowl over Pushover for this extension, because Prowl would auto-launch the "tel://" URL, whereas Pushover wouldn't.

 

The only think I can think of is maybe you have a security setting somewhere else on the iPhone that controls whether apps are allowed to act on custom URL schemes. But I don't know of any such thing. Any one else got any ideas?


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#13 BrianGilbert_

BrianGilbert_

    Member

  • Member
  • PipPip
  • 25 posts
  • LocationMelbourne, Australia

Posted 27 January 2013 - 07:31 AM

Actually, no. That's odd, because you shouldn't have to do anything. It should be automatically responding to the custom URL scheme, "tel://". That setting I mentioned before should only be the difference between asking or not asking to auto-launch the phone app. I've never had to actually click the notification. In fact, that's the main reason I chose Prowl over Pushover for this extension, because Prowl would auto-launch the "tel://" URL, whereas Pushover wouldn't.

 

The only think I can think of is maybe you have a security setting somewhere else on the iPhone that controls whether apps are allowed to act on custom URL schemes. But I don't know of any such thing. Any one else got any ideas?

I think I edited my message while you were typing your reply.. I've now got it working so that when I open Prowl the notification launches automatically.. but I still have to load Prowl.



#14 sphardy

sphardy

    Member

  • Member
  • PipPip
  • 81 posts

Posted 27 January 2013 - 08:02 AM

I've now got it working so that when I open Prowl the notification launches automatically.. but I still have to load Prowl.

FYI: I too have to click the prowl notification to launch the dialer. I had assumed that was how it was supposed to work



#15 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 368 posts
  • LocationAuckland, New Zealand

Posted 27 January 2013 - 08:11 AM

You have to click or swipe the original notification, but then Prowl should open then launch the phone call automatically.

 

Would probably be a bit dodgy if you didn't have to acknowledge the original notification - then anyone could just initiate calls (or launch dodgy URLs) from your phone without your approval.


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#16 BrianGilbert_

BrianGilbert_

    Member

  • Member
  • PipPip
  • 25 posts
  • LocationMelbourne, Australia

Posted 27 January 2013 - 08:25 AM

You have to click or swipe the original notification, but then Prowl should open then launch the phone call automatically.

 

Would probably be a bit dodgy if you didn't have to acknowledge the original notification - then anyone could just initiate calls (or launch dodgy URLs) from your phone without your approval.

Not unless they had access to my api key tho.. but yeah.. makes sense...



#17 judas

judas

    Member

  • Member
  • PipPip
  • 27 posts

Posted 14 February 2013 - 12:03 AM

Hi Carlos, I was testing your extension and it works wonderfully, except when a number contains parenthesis "(" ")"...then it says it is not valid. I mainly got it working by changing the phoneno replacement to:

 

phoneno=${arg//[-. '\(''\)']/}

 

but I'm still not happy with the results as it includes / symbols after the parenthesis in the {query} statements (both in notification center and in iPhone notifications), so it looks ugly. Can you think of a prettier way?



#18 judas

judas

    Member

  • Member
  • PipPip
  • 27 posts

Posted 14 February 2013 - 06:04 AM

Ok, so reply to my own self:

 

I wasn't able to strip the \ backslash before the ( ) parentheses in the {query}, so I created a new variable argumento that gets sent to prowl as the description:

 

argumento=${arg//[\\]/}

 

Also, I modified the notification so it does not show the \.

 

	echo "The number \""{query}"\" was successfully sent to your iPhone"

 

The complete code I am using now is:

 

#USER INFO:

#You'll need Prowl (http://www.prowlapp.com/) installed on your iphone. Once you've got your account set up, go to https://www.prowlapp.com/api_settings.php to retrieve your API key and enter it here:

PROWL_API_KEY=MY-PROWL-API-KEY

=========================================================

phoneno=$(echo "{query}" | tr -d ' ')		#strip spaces from Phone no.

#echo "Query1: {query}"
arg="{query}"
argumento=${arg//[\\]/}

#strip possible non-digit chars
phoneno=${arg//[-. '\(\)']/}

#Check that we're left with only digits
if [[ $phoneno = *[!0-9,+]* ]]; then
	echo "Sorry, \""{query}"\" is not a valid phone number."
	exit
fi


RESULT=$(curl -s -k https://prowl.weks.net/publicapi/add -F apikey=$PROWL_API_KEY -F application="Alfred" -F event="Open to call:" -F description="$argumento" -F url="tel://$phoneno")

if [[ "$RESULT" =~ "<success code=\"200\"" ]]; then
	echo "The number \""{query}"\" was successfully sent to your iPhone"
else
	echo "Oops. There was a problem. Number not sent."
fi


#19 CarlosNZ

CarlosNZ

    Advanced Member

  • Member
  • PipPipPip
  • 368 posts
  • LocationAuckland, New Zealand

Posted 14 February 2013 - 08:35 AM

Hi judas,

 

thanks for your feedback. I'll take this on board when I update it (which should probably be fairly soon as I've written a version that prompts for the API key rather than expecting the user to edit the actual script, which I plan to release soon.)  Good to see you've got a workaround for now though.

 

Any other characters I should allow through? Probably * and #, now that I think about it. 

 

Cheers,

C

 

:)


Twitter: @CarlosNZ | My Alfred Workflows: Carl's Geekzone

#20 sphardy

sphardy

    Member

  • Member
  • PipPip
  • 81 posts

Posted 14 February 2013 - 09:40 AM

Hi judas,

 

thanks for your feedback. I'll take this on board when I update it (which should probably be fairly soon as I've written a version that prompts for the API key rather than expecting the user to edit the actual script, which I plan to release soon.)  Good to see you've got a workaround for now though.

 

Any other characters I should allow through? Probably * and #, now that I think about it. 

 

Cheers,

C

 

:)

 

You might want to consider semicolons - used to insert a dial pause, eg when entering a id/pin for a conference call





Also tagged with one or more of these keywords: iphone, workflow, dial, phone, prowl

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users