Send push notification title to its invocation intent in Actions on Google

时间秒杀一切 提交于 2020-02-25 04:07:11

问题


I'm sending push notifications in Actions on Google (ref this official documentation).

So once I send the notification I'm sending title in it. So it looks like this, where A Very Happy Birthday, Jay Patel is the title that I've sent.

So once I click on the notification, it opens Google Assistant and invokes the intent (configured in this step), but it doesn't specify any contexts or other data regarding that notification so I'm not getting a person name that I've specified in title or any other data.

I want to know, is there anyway so that I can pass some data(title or any other data of notification) to the invocation intent when a person taps on the notification?

I'm getting this json response in my webhook when a person taps on the notification

    {  
   "responseId":"e2de9045-b415-kr45-be96-1a35779abcde",
   "queryResult":{  
      "queryText":"intent:send_push",
      "parameters":{  

      },
      "allRequiredParamsPresent":true,
      "fulfillmentText":"Latest update is here!",
      "fulfillmentMessages":[  
         {  
            "text":{  
               "text":[  
                  "Latest update is here!"
               ]
            }
         }
      ],
      "intent":{  
         "name":"projects/happierwork-bot/agent/intents/d1f4c032-28cf-4906-a393-6f2a612c0496",
         "displayName":"send_push"
      },
      "intentDetectionConfidence":1.0,
      "languageCode":"en-in"
   },
   "originalDetectIntentRequest":{  
      "source":"google",
      "version":"2",
      "payload":{  
         "user":{  
            "userId":"my_id",
            "accessToken":"my_token",
            "permissions":[  
               "UPDATE"
            ],
            "locale":"en-IN",
            "lastSeen":"2018-10-09T05:57:18Z"
         },
         "conversation":{  
            "conversationId":"ABwppHE7XKXDdjfjSRPF_OCVttGKMavfasdffngesQEI2Jy11Q8fp8lNXgpgGtFe7KCxK3WWey-1ColL7",
            "type":"NEW"
         },
         "inputs":[  
            {  
               "intent":"send_push",
               "rawInputs":[  
                  {  
                     "inputType":"URL",
                     "url":"bot_url?intent=send_push"
                  }
               ],
               "arguments":[  
                  {  
                     "name":"UPDATES",
                     "boolValue":true
                  }
               ]
            }
         ],
         "surface":{  
            "capabilities":[  
               {  
                  "name":"actions.capability.WEB_BROWSER"
               },
               {  
                  "name":"actions.capability.AUDIO_OUTPUT"
               },
               {  
                  "name":"actions.capability.SCREEN_OUTPUT"
               },
               {  
                  "name":"actions.capability.MEDIA_RESPONSE_AUDIO"
               }
            ]
         },
         "isInSandbox":true,
         "availableSurfaces":[  
            {  
               "capabilities":[  
                  {  
                     "name":"actions.capability.WEB_BROWSER"
                  },
                  {  
                     "name":"actions.capability.AUDIO_OUTPUT"
                  },
                  {  
                     "name":"actions.capability.SCREEN_OUTPUT"
                  }
               ]
            }
         ]
      }
   },
   "session":"projects/myproject-bot/agent/sessions/ABwppHE7XKXDdjfjSRPF_OCVtasdffagbKiGKA9sCsQEI2Jy11Q8fp8lNXgpgGtFe7KCxK3WWey-1ColL7"
}

回答1:


You can supply argument data using the argument field of the push message target.

Please view the reference for more detail: https://actions-on-google.github.io/actions-on-google-nodejs/2.12.0/interfaces/_service_actionssdk_api_v2_.googleactionsv2custompushmessagetarget.html



来源:https://stackoverflow.com/questions/52714377/send-push-notification-title-to-its-invocation-intent-in-actions-on-google

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!