CarlosNZ

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

42 posts in this topic

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
sphardy likes this

Share this post


Link to post

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

Share this post


Link to post

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.

Share this post


Link to post

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

Share this post


Link to post
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.

Share this post


Link to post

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...

Share this post


Link to post
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. ;)

Share this post


Link to post
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?

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post

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.

Share this post


Link to post
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...

Share this post


Link to post

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?

Share this post


Link to post

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

Share this post


Link to post

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

 

:)

Share this post


Link to post

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

Share this post


Link to post

So I checked the iOS dialer, and it allows the following characters:

Numerals 0-9

#

+

*

, (pause)

; (wait)

And it formats numbers with

(

)

-

But this are not actually dialed, so they could be sent or stripped from the number

Now that I think about it, letter could be allowed to and converted into numbers, to allow dialing word numbers (1800 COLLECT) and so on.

ABC 2

DEF 3

GHI 4

JKL 5

MNO 6

PQRS 7

TUV 8

WXYZ 9

Great to see your working on it! Thanks!

Share this post


Link to post

I have the original workflow working fine with Prowl. I would like to test Pushover. How do I modify the workflow so that it calls Pushover instead of Prowl? I have Pushover set up and working but not talking to Alfred. 

Share this post


Link to post

Hey folks,

 

I've updated the workflow to allow for the punctuation characters that can be in a valid phone number (brackets, *, #, etc). Also, now has a GUI prompt for your API key rather than requiring the user to manually edit the code.

 

Hope it works well for you all.

 

C

daxdavis likes this

Share this post


Link to post

 Now that I think about it, letter could be allowed to and converted into numbers, to allow dialing word numbers (1800 COLLECT) and so on.

ABC 2

DEF 3

GHI 4

JKL 5

MNO 6

PQRS 7

TUV 8

WXYZ 9

 

That's a really cool idea. I might have to try that at some point.

Edited by CarlosNZ

Share this post


Link to post

I have the original workflow working fine with Prowl. I would like to test Pushover. How do I modify the workflow so that it calls Pushover instead of Prowl? I have Pushover set up and working but not talking to Alfred. 

 

Hi Denise. Sorry for my slow response.

 

As a crude measure for now, you can try this:

 

In the main workflow script (dialer.sh in the workflow folder), change the following line:

 

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="$1" -F url="tel://$phoneno")

to this:

RESULT=$(curl -s -k https://api.pushover.net/1/messages.json -F token=51ugTC0xmfd3GqiyukQVf1BmJou9eA -F user=$PROWL_API_KEY -F message="Dial number: $phoneno" -F url="tel://$phoneno")

Be aware, though, that the response code from Pushover will be different, and so the workflow will give you an error saying it failed to send even when it works. If this is bothering you, just delete all the code after the aforementioned line and you'll get no notification at all.

 

I've managed to get it to work for me, but haven't done any extensive testing, so good luck. Hopefully I'll get around to adding proper Pushover support in a later update. (If others are interested in this, let me know, as it'll motivate me to get to it sooner rather than later.)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now