dialogflow / dialogflow-fulfillment-nodejs

Dialogflow agent fulfillment library supporting v1&v2, 8 platforms, and text, card, image, suggestion, custom responses
Apache License 2.0
597 stars 281 forks source link

Custom Payload, Facebook, Include persona_id #289

Open aintHuman opened 4 years ago

aintHuman commented 4 years ago

According to the relatively new FB Beta Functionality, custom persona_id's can be incorporated into messages, taking the following form (Source: HERE):

curl -X POST -H "Content-Type: application/json" -d '{
  "recipient":{
      "id":"<USER_PSID>"
   },
  "message":{
      "text":"hello world!",
   },
  "persona_id": "<PERSONA_ID>"
 }' "https://graph.facebook.com/me/messages?access_token=<PAGE_ACCESS_TOKEN>"

Now the issue, as far as I can see it, is that in terms of trying to use this new (and potentially highly attractive feature) in the dialogflow-fullfillment-nodejs library, is that when a custom payload is provided (such as outlined HERE)

then it might take the following form:

let message = {"text":"hello world!"}
let payload = new Payload(agent.FACEBOOK, message)
agent.add(payload)

And this prohibits injecting the "persona_id" at the correct nesting level in the overall json packet as specified by the FB documentation.

Any suggestions?

gayaniprogressive commented 3 years ago

Hi did you manage to find a resolution?