jgorset/facebook-messenger

Best way to use bot analytics providers?

Open

#178 aberto em 4 de out. de 2017

Ver no GitHub
 (2 comments) (1 reaction) (0 assignees)Ruby (215 forks)github user discovery
good first issuehelp wanted

Métricas do repositório

Stars
 (970 stars)
Métricas de merge de PR
 (Métricas PR pendentes)

Description

Since this gem creates a new message object different from the incoming payload, I was wondering whether anybody had thoughts on best way to integrate with bot analytics vendors?

Below is the json data that needs to be passed to typical vendors like dashbot.io via REST.

INCOMING

{
  "object": "page",
  "entry": [
    {
      "id": "943703799078240",
      "time": 1483257600000,
      "messaging": [
        {
          "sender": {
            "id": "1018952661536494"
          },
          "recipient": {
            "id": "943703799078240"
          },
          "timestamp": 1483257600000,
          "message": {
            "mid": "mid.1468531733396:9242db91fea253e355",
            "seq": 978,
            "text": "Hi, bot"
          }
        }
      ]
    }
  ]
}

OUTGOING

{
  "qs": {
    "access_token": "<YOUR ACCESS TOKEN>"
  },
  "uri": "https://graph.facebook.com/v2.6/me/messages",
  "json": {
    "message": {
      "text": "Hello, my human pet"
    },
    "recipient": {
      "id": "975099989272315"
    }
  },
  "method": "POST",
  "responseBody": {
    "recipient_id": "975099989272315",
    "message_id": "mid.1470371655004:4727480467538e9450"
  }
}

Guia do colaborador