2

I have created a Dynamic card in Dialogflow that should display in hangouts. Here is the custom card i have created in Dialogflow responses under custom payload:

{
  "hangouts": {
    "header": {
      "imageUrl": "imageurl",
      "title": "Hi, Select your choice ?"
    },
    "sections": [
      {
        "widgets": [
          {
            "buttons": [
              {
                "textButton": {
                  "text": "Card",
                  "onClick": {
                    "action": {
                      "actionMethodName": "CardResponder"
                    }
                  }
                }
              },
              {
                "textButton": {
                  "text": "Cash",
                  "onClick": {
                    "action": {
                      "actionMethodName": "CashResponder"
                    }
                  }                  
                }
              }
            ]
          }
        ]
      }
    ]
  }
}

The card looks like this in hangouts. card

In the webhook code my entry point is this:

app.post('/', express.json(), (req,res)=>{
    if(req.body.queryResult.intent.displayName == "PaymentIntent"){
        ........
    }    
});

I am not able to detect the event when i click on Cash or Card button on my hangouts dynamic card. I have defined function name as well in the actionMethodName parameter. But I am not sure how to write that function in my webhook code. Please help me.

Update

app.post('/', express.json(), (req,res)=>{
    console.log(req.body);
    console.log(req.body.action.actionMethodName);
    
});

I am trying to console req.body which gives me

originalDetectIntentRequest: { source: 'hangouts', payload: { data: [Object] } },

req.body.action.actionMethodName gives undefined.

When i try to click button in hangouts card it gives me this error - Unable to contact hangouts-bot. Try again later.

hangouts-bot is the name of my cloud project. I do not know how to recieve the click request in my node js code.

Richi
  • 33
  • 4
  • From your question I don't know if you are actually getting the request and you don't know how to manage that request or if you are not getting the request at all. Try to clarify that please. If it's the former you should try to read [the documentation about it](https://developers.google.com/hangouts/chat/how-tos/cards-onclick). – Raserhin Oct 23 '20 at 16:10
  • @Raserhin I have added update in my post. When i click the button in the card i am not sure how can i recieve that in my code. – Richi Oct 28 '20 at 07:17
  • Could you maybe expand on the `data` object. Maybe you should trying to get the `actionMethodName` from that `payload` and not directly from the body. – Raserhin Nov 02 '20 at 10:48

0 Answers0