Message from the front to the server

Here is the Facebook documentation: https://developers.facebook.com/docs/messenger-platform/webhook-reference/message

The PAGE_ID is the same as the appID in Vizir.
_I will defined USER_ID later, we can use the same USER_ID by now

  • Message text
{
  "sender":{
    "id":"USER_ID"
  },
  "recipient":{
    "id":"PAGE_ID"
  },
  "timestamp":1458692752478,
  "message":{
    "text":"hello, world!"
  }
}

If the user click on a quick replies button, here is the message that the front should send to the server

{
  "sender":{
    "id":"USER_ID"
  },
  "recipient":{
    "id":"PAGE_ID"
  },
  "timestamp":1458692752478,
  "message":{
    "text":"hello, world!",
    "quick_reply": {
      "payload": "DEVELOPER_DEFINED_PAYLOAD"
    }
  }
}
  • Message with an image (possible to upload image from the input box)
{
  "sender":{
    "id":"USER_ID"
  },
  "recipient":{
    "id":"PAGE_ID"
  },
  "timestamp":1458692752478,
  "message":{
    "attachments":[
      {
        "type":"image",
        "payload":{
          "url":"IMAGE_URL"
        }
      }
    ]
  }
}
  • Click "postback" button (bouton de renvoie sur la doc facebook)
{
  "sender":{
    "id":"USER_ID"
  },
  "recipient":{
    "id":"PAGE_ID"
  },
  "timestamp":1458692752478,
  "postback":{
    "payload": USER_DEFINED_PAYLOAD,
  }
}

Starting a new conversation (The first time the user will see the bot on a website)

Case N°1 : The user open the bot via the "classic" url on a website: http://vizir.co/#/appID

{
  "sender":{
    "id":"USER_ID"
  },
  "recipient":{
    "id":"PAGE_ID"
  },
  "timestamp":1458692752478,
  "message":{
    "text":"_init_"
  }
}

Case N°2 :
We want for any reason that the person starts the conversation at a different point. We can pass a parameter in the url in order the user to start with another part of the bot.

If the parameter ?ref is on the url we should send this kind of message to the server.

example url :

http://bot.vizir.co/app/9876543245678765?ref=Benoit
{
  "sender":{
    "id":"<USER ID>"
  },
  "recipient":{
    "id":"<PAGE ID>"
  },
  "timestamp":1458692752478,
  "referral": {
    "ref": "Benoit",
    "source": "SHORTLINK"
  }
}

Case N°3 : The owner wants to know who is answering the bot, it is possible to pass a parameter through the url like that:
So if the uid is present we will use it as the senderID

http://bot.vizir.co/app/9876543245678765?ref=Benoit&uid=999

Le message à envoyer au server sera alors

{
  "sender":{
    "id":"999"
  },
  "recipient":{
    "id":"<PAGE ID>"
  },
  "timestamp":1458692752478,
  "referral": {
    "ref": "Benoit",
    "source": "SHORTLINK"
  }
}

results matching ""

    No results matching ""