Search code examples
dialogflow-esactions-on-google

Is it possible to check whether a button has been clicked or not in actions on google?


At the end of the conversation I am creating a basic card which asks for a review. If the user does give a review I don't want to ask them again the next time. So what would be the best way to do so ? At the moment I am wondering whether I can track whether they have clicked on the button which leads to the review link provided in the BasicCard or not.


Solution

  • The link button does not report anything back to your fulfillment, so there is no direct way to know if the link has been clicked.

    One possible workaround is a little convoluted, but would let you track if the link has been followed. It assumes, however, that you are storing a unique userid in the user storage (and that this is allowed in your jurisdiction). In this case what you can do is

    1. When you generate the card, the link would go to another URL that you control - not the review URL directly.
    2. The link would also include a parameter that includes the userid you've generated for them.
    3. At the code running at this link, you get the userid parameter, mark in the database that they've been sent to the review page, then redirect them to the review page.

    In future conversations, you can get the userid from their user storage and check your own records to see if they've been sent to the review page. From here, you can decide if you want to show the card, include the link, etc.