domdomegg
domdomegg

Reputation: 1806

Initiating a phone call

Is it possible yet to initiate a phone call? E.g. if I'm making a branch finder action a dialogue might go like:

"Hi, where's my nearest store?"
"Your nearest store is our Oxford Street branch, at 300 Oxford St, Marylebone."
"Call it"
"Sure"

It then initiates a call to the store, like an Android app using an ACTION_DIAL intent.

I would think something like this should be possible, especially considering the current devices supporting Assistant are phones and Google Home, both of which can make calls (I guess future devices with assistant built in might not, but then there can be a check like app.phoneCapabilities). I've tried using .addSuggestionLink with a tel: address with no luck.

Upvotes: 4

Views: 1589

Answers (3)

Jay Patel
Jay Patel

Reputation: 2451

You can show a call button which will redirect to the specified number on the dialer app.

Here's a way to do that from fulfillment response:

"buttons": [
   {
    "title": "Call",
    "openUrlAction": {
        "url": "tel:+91123456789",
        "androidApp": {
            "packageName": "com.android.phone"
        },
        "versions": []
    }
  }
]

Add this JSON to your response and it will show a button which will redirect to default call app and shows +91123456789 number filled.

EXTRA

Similarly, if you want to send mail then you can add:

{
    "title": "Send Mail to Jay",
    "openUrlAction": {
        "url": "mailto:[email protected]",
        "androidApp": {
            "packageName": "android.intent.extra.EMAIL"
        },
        "versions": []
    }
}

Upvotes: 0

domdomegg
domdomegg

Reputation: 1806

I actually made a dodgy work around for this, if anyone comes back to this and is interested.

You can suggest a webpage URL, which can be a page which has a tel: link from there. Either using server side work or just simple JavaScript (mine uses simple JavaScript), you can update the link.

My link is below - feel free to use it, I use it in my app. It's pretty basic, the documentation is in the comments:

https://domdomegg.github.io/linkgenerator?href=tel%3A%2B442070313000&bgcolor=607d8b&buttontext=Click%20to%20call%20Google

Upvotes: 3

Prisoner
Prisoner

Reputation: 50701

For starters, the Google Home cannot (yet) make calls. That feature was announced at I/O and will be rolling out later this year. It is not yet known if there will be API access to that feature when it does roll out. (There is certainly potential for abuse of the feature, although there are some ways that can mitigate that abuse.)

I haven't tested, but I'm a little surprised that the tel: url form didn't work since I thought that would just launch an intent on Android (tho I don't know how iOS would handle it) and tel: goes to the dialer intent.

Upvotes: 2

Related Questions