65639

Facebook Messenger API: Send Structured Message

Question:

When following <a href="https://developers.facebook.com/docs/messenger-platform/quickstart" rel="nofollow">this example</a>.

messageData = { "attachment": { "type": "template", "payload": { "template_type": "generic", "elements": [{ "title": "First card", "subtitle": "Element #1 of an hscroll", "image_url": "http://messengerdemo.parseapp.com/img/rift.png", "buttons": [{ "type": "web_url", "url": "https://www.messenger.com/", "title": "Web url" }, { "type": "postback", "title": "Postback", "payload": "Payload for first element in a generic bubble", }], },{ "title": "Second card", "subtitle": "Element #2 of an hscroll", "image_url": "http://messengerdemo.parseapp.com/img/gearvr.png", "buttons": [{ "type": "postback", "title": "Postback", "payload": "Payload for second element in a generic bubble", }], }] } }

I receive an error of:

<blockquote>

\"error\":{\"message\":\"(#100) Incomplete element data: title and at least one other field (image url, subtitle or buttons) is required with non-empty value\",\"type\":\"OAuthException\",\"code\":100,\"fbtrace_id\":\"ElbXaF25+0G\"}

</blockquote>

Am I missing something? Looks to me that all the relevant fields are present.

Answer1:

Figured it out, writing this in ruby and I needed to call to_json on the hash before sending it.

Answer2:

Yes, Before sending need to convert to json format Either it is a structured message Or text message.

Recommend

  • TextView catch clicking on link when autoLink is set to “web”
  • instructions for Facebook Like- Button
  • Facebook messenger bot app - persistent menu not appearing
  • Android Matcher and Pattern cut up from the link
  • Spark MLib Word2Vec Error: The vocabulary size should be > 0
  • how to get QR code type
  • JavaFX - Border radius Background color
  • HTML Offline Application Cache, Listing Downloaded Files
  • Chef - how to write a custom resource containing DSL for “execute”
  • how to replace string in SpEL expression?
  • dask distributed memory error
  • How to put “new line” in Spring Expression Language?
  • Metadata in PDF Files
  • Insert Arraylist in Database in Mule
  • How to validate DTD against XML in Node.js
  • Prevent session from being replicated when JSESSIONID cookie copied
  • MySQL performance using AUTO_INCREMENT on a PRIMARY KEY
  • How to Control or Stop Partial Post Back in Update Panel
  • Creating a Messenger service
  • add new field to form with rvest
  • Passing Props from State to Child
  • Creating a Multi-Step Modal Using Jquery
  • Mocha throws unexpected token error for ES6 object spread operator
  • Outputting SharePoint Hyperlink Column as URL
  • didUpdatePushCredentials not get called
  • Floated image with variable width and heading with background image
  • Disable Kendo Autocomplete
  • How to view images from protected folder with php?
  • Debug.DrawLine not showing in the GameView
  • How to have background script and something similar to a default popup?
  • Android full screen on only one activity?
  • Python urlparse: small issue
  • Adding custom controls to a full screen movie
  • GridView Sorting works once only
  • Circular dependency while pushing http interceptor
  • Revoking OAuth Access Token Results in 404 Not Found
  • AngularJs get employee from factory
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass