Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Postback / Suggestion Messages / Button Click Events #848

Closed
steffh opened this issue Feb 2, 2021 · 4 comments · Fixed by #1066
Closed

Handle Postback / Suggestion Messages / Button Click Events #848

steffh opened this issue Feb 2, 2021 · 4 comments · Fixed by #1066
Assignees
Labels
Milestone

Comments

@steffh
Copy link
Collaborator

steffh commented Feb 2, 2021

  • As an Airy developer trying to consume relevant events via the webhook,
    WHEN a postback event (Facebook standard) or Suggestion Messages event (Google standard) or Button Click event (WhatsApp standard) is received by the Airy ingestion layer because an end user clicked on a button at any source supporting such feature,
    THEN I want to receive the relevant postback.payload (Facebook standard) or suggestionResponse.postbackData (Google standard) or messages.button.payload (WhatsaApp standard) from such event via the webhook

  • As an Airy messaging UI user trying to see which buttons an end user has clicked on at any source supporting such feature,
    WHEN a postback event (Facebook standard) or Suggestion Messages event (Google standard) is received by the Airy ingestion layer,
    THEN I want to see a rendered message in the Airy messaging UI containing the postback.title (Facebook standard) or suggestionResponse.text (Google standard) or messages.button.title (WhatsaApp standard)

Developer Notes:

Postback Event (Facebook standard):

https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messaging_postbacks/

{
  "sender":{
    "id":"<PSID_IN_CASE_OF_IDENTIFIED_USER>"
    "user_ref":"<USER_REF_PARAMETER_IN_CASE_OF_NO_PSID>"
  },
  "recipient":{
    "id":"<PAGE_ID>"
  },
  "timestamp":1458692752478,
  "postback":{
    "title": "<TITLE_FOR_THE_CTA>",  
    "payload": "<USER_DEFINED_PAYLOAD>",
    "referral": {
      "ref": "<USER_DEFINED_REFERRAL_PARAM>",
      "source": "<SHORTLINK>",
      "type": "OPEN_THREAD",
    }
  }
}   

Suggestion Messages event (Google Standard):

https://developers.google.com/business-communications/business-messages/guides/build/receive#suggestion

{
  "agent": "brands/BRAND_ID/agents/AGENT_ID",
  "conversationId": "CONVERSATION_ID",
  "customAgentId": "CUSTOM_AGENT_ID",
  "requestId": "REQUEST_ID",
  "suggestionResponse": {
    "message": "conversations/CONVERSATION_ID/messages/MESSAGE_ID",
    "postbackData": "POSTBACK_DATA",
    "createTime": "RESPONSE_CREATE_TIME",
    "text": "SUGGESTION_TEXT",
    "suggestionType": "SUGGESTION_TYPE",
  }
  "context": {
    "entryPoint": "CONVERSATION_ENTRYPOINT",
    "placeId": "LOCATION_PLACE_ID",
    "resolvedLocale": "MATCH_OF_USER_AND_AGENT_LOCALES",
    "userInfo": {
      "displayName": "USER_NAME",
      "userDeviceLocale": "USER_LOCALE",
    },
  },
  "sendTime": "SEND_TIME",
}

Button Click event (WhatsApp Standard):

https://developers.facebook.com/docs/whatsapp/api/messages/message-templates/interactive-message-templates#callback-from-a-quick-reply-button-click

{
    "contacts": [
        {
            "profile": {
                "name": "Kerry Fisher"
            },
            "wa_id": "16505551234"
        }
    ],
    "messages": [
        {
            "button": {
                "payload": "No-Button-Payload",
                "text": "No"
            },
            "context": {
                "from": "16315558007",
                "id": "gBGGFmkiWVVPAgkgQkwi7IORac0"
            },
            "from": "16505551234",
            "id": "ABGGFmkiWVVPAgo-sKD87hgxPHdF",
            "timestamp": "1591210827",
            "type": "button"
        }
    ]
    # If there are any errors, an errors field (array) will be present        
    "errors": [ { ... } ]
}
@chrismatix
Copy link
Contributor

@steffh some points/questions: Currently we only support WhatsApp via Twilio and get the data in an URL encoded format. So the integration that you linked is not there yet and I suppose we would need another issue for it.

Could you detail a bit where you would like the source-specific payloads to show up in the current payload?

{
  "conversation_id": "4242424242",
  "id": "7560bf66-d9c4-48f8-b7f1-27ab6c40a40a",
  "sender": {
    "id": "adac9220-fe7b-40a8-98e5-2fcfaf4a53b5",
    "type": "source_contact"
  },
  "source": "facebook",
  "sent_at": "2020-07-20T14:18:08.584Z",
  "content": '{"text":"Hello World"}'
}

Currently, the payload looks like so and since the improvement to our data model - which you kickstarted - the content field should contain the data you are asking for. So does that mean that you want us to extract it separately?

@chrismatix
Copy link
Contributor

We had an offline conversation about this and decided that because of the points raised above, the backend part of this ticket is already done.

@chrismatix chrismatix removed their assignment Feb 22, 2021
@bitboxer
Copy link
Contributor

bitboxer commented Feb 22, 2021

The google part of this ticket was implemented in #1040

@bitboxer bitboxer self-assigned this Feb 22, 2021
@bitboxer
Copy link
Contributor

I will now fix the missing Facebook renderer for the postbacks. As dicussed above we don't have a real whatsapp integration and will need to cover that in a separate ticket.

bitboxer added a commit that referenced this issue Feb 23, 2021
bitboxer added a commit that referenced this issue Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants