Sending notifications with Google Assistant January 08, 2024 23:52 Updated Currently, integration with the Google Assistant channel is only available for Enterprise users. Generate a key Step 1: Open this URL, replacing "HERE" with the Project ID of your Actions project: https://console.developers.google.com/apis/api/actions.googleapis.com/overview?project=HERE Step 2: If you see an “Enable” button, click on it. If not, proceed to step 3. Step 3: Open this URL, replacing the "HERE" at the end with the Project ID of your Actions project: https://console.developers.google.com/apis/credentials?project=HERE Step 4: Click on Create credentials> Service Account Key. Step 5: In the Service Account selection box, choose New Service Account. Step 6: Name the account as “notifications” and change the Role to Project> Owner. Step 7: Choose JSON for the key type and click Create. A JSON file with the service account key will be downloaded to your computer. Step 8: The file will look like this: Step 9: Copy and paste the contents of the file in the advanced bot settings, as follows (put this in the last channel configuration screen): a) Domain: postmaster@assistant.gw.msging.net b) Key: ServiceCredentialJson c) Value: content of the downloaded file. Step 10: Create another entry in the advanced settings table, with the key being DefaultPushClickMessage(put this in the last channel configuration screen). The value will be the message sent by default to the bot whenever a user clicks on a push notification. It is not possible to differentiate which push was clicked or when. You need to configure two new actions in the Actions On Google app. Just change the actions.json file, created earlier, to have the two new actions following the pattern. a) An action to deal with the permission given or denied (PERMISSION) and b) An action to handle the user's click on an application notification (iris.assistant.intent.PUSH_CLICKED). { "actions": [ { "description": "Default Welcome Intent", "name": "MAIN", "fulfillment": { "conversationName": "IRISBot" }, "intent": { "name": "actions.intent.MAIN", "trigger": { "queryPatterns": [ "talk to IRISBot", "I want to talk to IRISBot" ] } } }, { "description": "Permission", "name": "PERMISSION", "fulfillment": { "conversationName": "IRISBot" }, "intent": { "name": "actions.intent.PERMISSION", "trigger": { "queryPatterns": [ "interact with push notification" ] } } }, { "description": "Push Interaction Intent", "name": "PUSH_CLICKED", "fulfillment": { "conversationName": "IRISBot" }, "intent": { "name": "iris.assistant.intent.PUSH_CLICKED", "trigger": { "queryPatterns": [ "interact with push notification" ] } } } ], "conversations": { "IRISBot": { "name": "IRISBot", "url": "https://assistant.gw.msging.net/irisbot-624c5" } }, "locale": "en"} And send it back to Actions on Google, using the gactionscommand. With that, two new actions will appear in the panel, under Build> Actions: Enter the new push interaction action and go to the “User engagement” section, where you must select the option to want to send push notifications. Fill in the “Content title” with your preferred name (the notification will be displayed using this name, which will also be used to request permission to send notifications, eg: “Would you like to receive notifications for your bot's Name?”). Save at the top of the page, on the right. However, before you can send notifications, it is necessary to ask for the person's permission and save their id and which intent will be used to receive the notifications (it will be the PUSH_CLICKED intent created above), if the person allows the notifications. First, ask if the person wants the notifications and, if they do, the gateway should return a response with possible intent as follows: {"expectedInputs": [ { "inputPrompt": { "richInitialPrompt": { "items": [ { "simpleResponse": { "textToSpeech": "PLACEHOLDER" } } ] } }, "possibleIntents": [ { "intent": "actions.intent.PERMISSION", "inputValueData": { "@type": "type.googleapis.com/google.actions.v2.PermissionValueSpec", "permissions": [ "UPDATE" ], "updatePermissionValueSpec": { "intent": "iris.assistant.intent.PUSH_CLICKED" } } } ] } ],} To this end, the person's response will be received, whether or not they grant permission. Return some message to the person saying they saved the permission. To send notifications, a custom push message must be sent to the Assistant, marking the desired user on the target and sending the notification title: { "customPushMessage": { "userNotification": { "title": "este é um título" }, "target": { "userId": "ABwppHEdPIEOjDg9SSFaUeaV9Uc8JoFDs1Kchrj4RgIS8fauKNfpr3K5ag", "intent": "iris.assistant.intent.PUSH_CLICKED", "locale": "en-US" } }} The notification will appear as follows: a) “this is a title”: title sent. b) “IRISBot”: Name set for the action, when configuring user engagement. c) “Mary Anne”: Name used to invoke the bot in the Image Assistant: Image of the application chosen in the Actions panel. For more information, visit the discussion on the subject in our community or the videos on our channel. 😃 Related articles How to Send Notifications via the Active Campaign API (Growth) How to send SMS via Scheduler How to add push notifications to BLiP Chat Android Sending WhatsApp Active Messages on Blip Desk Configuring payments in the Blip builder