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

Best way to use bot analytics providers? #178

Open
echan00 opened this issue Oct 4, 2017 · 2 comments
Open

Best way to use bot analytics providers? #178

echan00 opened this issue Oct 4, 2017 · 2 comments

Comments

@echan00
Copy link

echan00 commented Oct 4, 2017

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"
  }
}
@jgorset
Copy link
Owner

jgorset commented Mar 30, 2018

Oh, cool, I never thought of this. You can get at the original object at message.messaging, though, so you can pass it to the analytics service in your code using that.

@jgorset
Copy link
Owner

jgorset commented Mar 30, 2018

I'll leave this open and tag accordingly if someone wants to add it to the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants