Form designer for Facebook Messenger apps? - facebook

I'm a veteran programmer, however I am new to the Facebook Messenger API. I have seen that the API does support buttons as per this code snippet from the Facebook developers web site that uses a CURL example to demonstrate the formatting code:
https://developers.facebook.com/docs/messenger-platform/send-api-reference/button-template
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"USER_ID"
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"button",
"text":"What do you want to do next?",
"buttons":[
{
"type":"web_url",
"url":"https://petersapparel.parseapp.com",
"title":"Show Website"
},
{
"type":"postback",
"title":"Start Chatting",
"payload":"USER_DEFINED_PAYLOAD"
}
]
}
}
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=PAGE_ACCESS_TOKEN"
This looks like typical JSON to me. Is there a GUI tool that can design these layout elements, not only for buttons, but for any other Facebook Messenger form template elements that may also exist in the API? Something that uses a drag and drop or other GUI interface that then generates the necessary JSON code or fragment to represent the designed form?
If so, please leave its name or a link to it.

There is the Platform Design Kit for Sketch: https://developers.facebook.com/docs/messenger-platform/design-resources/design-kit

Related

facebook messenger send message api without the user initiating the chat

I have a facebook page, and a website too. I need to add a button to my website, like "SEND THIS ARTICLE ON MESSENGER". When the user clicks on it, I need to send the article data to the user on messenger.
How can I achieve that?
To achieve your goal, You must have to use SEND TO MESSENGER Button.
Ref.: https://developers.facebook.com/docs/messenger-platform/discovery/send-to-messenger-plugin/
Full process to implement:
1. Need to integrate Facebook Div in your site
2. Add Facebook script
3. Once Any User press the button than You got the webhook event from the facebook which contatin the PSID.
4. Through this PSID You can sent the messege to that id.
If you are sending message using curl than following is the code
curl -X POST -H "Content-Type: application/json" -d '{
"recipient": {
"id": "<PSID>"
},
"message": {
"text": "hello, world!"
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=<FB_PAGE_TOKEN>";

How to add 'Get Started' button in facebook messenger chat bot?

I tried using this
curl -X POST -H "Content-Type: application/json" -d '{ "get_started": {"payload": "qr"} }' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=myPageAccessToken"
In response I also got { "result": "success" }
But the bot does not show any button.
First, make sure that your account facebook who try to use your bot since only admins/developers/testers of the app can see it when the app is in development.
Second, if you use Android, you need to clear the Messenger data/cache under Android Settings -> Apps, this will also clear your login and you need to login again.
For further information, you could check this out:
https://stackoverflow.com/a/42662751/6874563
It was working fine, All I had to do was, deleting the existing conversion.
In my case, get started button only appears, when there's no message exists in past.

LinkedIn: Creating a company share for a photo

I'm suffering to create a company photo share on Linkedin.
I've seen several threads, where people say, they could create a photo share on LinkedIn by creating a link share, passing the image URL for the "submitted-url".
E.G. Consider the following payload:
```
{
"visibility": { "code": "anyone" },
"content": {
"submitted-url": "localhost/image.jpg"
}
}
```
In my case, at least, the share appears as a link share on LinkedIn. I've also tried the combinations of providing the "title" etc. fields, but no luck.
Next, I've found the following documentation: https://developer.linkedin.com/docs/guide/v2/shares/rich-media-shares#upload
That does not seem to be linked from the https://developer.linkedin.com/docs, so I have no clue if this documentation still applies.
I've tried the following endpoint: "https://api.linkedin.com/media/upload" with the "Content-Type: application/x-www-form-urlencoded" and "Authorization: Bearer ..." -headers, with file payload but the response is:
```
{
"serviceErrorCode": 100,
"message": "Not enough permissions to access media resource",
"status": 403
}
``
It does not matter, what permissions I have set for my app.
I happen to know from some applications, there is a way to share photo shares on LinkedIn via the API, but I don't manage to find the correct documentation where this is described.
If you know a way that worked for you but isn't already listed here, please inform me and all the others suffering from this problem :)
And if someone from LinkedIn could add the proper documentation, that would be superb!
Thanks!
Meanwhile, our application got accepted to LinkedIn "marketing partner" program which gives you access to LinkedIn API V2, the documentation is publicly available, but you need to manually apply for it. They may or may not accept your application.
Just couple gotchas for the next person who may struggle with this or some other issues we encountered.
Once our application got accepted to the "marketing partner"-program, we started to receive strange errors for our LinkedIn v1 API calls, namely "410 Gone" - "This resource is no longer available under v1 APIs".
All the calls using the application that got the permissions to API v2 were failing to this error. There was no way to use the old API with that application any longer.
The email confirming our application's acceptance to the program was sent to us in one day delay from when these problems started. Strange way to deal API switch, but luckily we have access to API v2 now.
LinkedIn API v2 gives you the possibility to upload and publish photo shares (one or many photos), which isn't possible with API v1.
The error we received for every call to API v1 after the acceptance:
{
"status": 410,
"message": "This resource is no longer available under v1 APIs",
"errorCode": 0,
"requestId": "removed",
"timestamp": 1522333590761
}
LinkedIn provides rich media API to do an image share.
Lets assume you already have an access token (access_token), your organization id is org_id and the image file name is "flower.png"
1) Below call helps you to upload the image to LinkedIn using upload media API
curl -X POST \
https://api.linkedin.com/media/upload \
-H 'authorization: Bearer <access_token>’ \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-F fileupload=#flower.png
The above call returns the below response format:
{
"location": “<image_urn>“
}
2) Now using the above image_urn in response, you will be able to create an image share using the below call
Please replace access_token, org_id and image_urn with the original values before making the below call
curl -X POST \
https://api.linkedin.com/v2/shares \
-H 'authorization: Bearer <access_token>’ \
-H 'content-type: application/json' \
-d '{ "owner": "urn:li:company:<org_id>“,
"text": {
"text": "test image attachemnt 0614"
},
"subject": "test image attachemnt 0614",
"distribution": {
"linkedInDistributionTarget": {}
},
"content":{
"contentEntities": [
{
"entity": “<image_urn>”
}
],
"description": "content description1",
"title": "Test Share with Image"
}
}'

How do you get the attachment link after uploading a video media via Facebook Messenger Upload API?

We're trying to retrieve an attachment that we uploaded via Facebook Messenger Upload API, but we can't seem to get any info about the attachment link. We only have the attachment id.
Is there a way to get the attachment link?
I got this working now. I basically need to create an attachment payload passing only the attachmend_id.
curl -X POST -H "Content-Type: application/json" -d '{
"recipient": {
"id": "USER_ID"
},
"message": {
"attachment": {
"type": "image",
"payload": {
"attachment_id": "1745504518999123"
}
}
}
}' "https://graph.facebook.com/me/messages?access_token=PAGE_ACCESS_TOKEN"
This will send the existing attachment to the user.

Facebook and Parse: Code 251, Error: Parse::InvalidSessionError

I'm trying to set up a chrome extension that uses a Facebook Access token to login to Parse using the JS api. As a proof of concept I tried following the example here with curl, but when I put in my access_token and expiration_date, the POST call returns {"code":251,"error":"Parse::InvalidSessionError"}
Specifically, I'm calling this from the OSX shell.
curl -X POST
-H "X-Parse-Application-Id: [my app id]" \
-H "X-Parse-REST-API-Key: [my rest api key]" \
-H "X-Parse-Revocable-Session: 1" \
-H "Content-Type: application/json" \
-d '{
"authData": {
"facebook": {
"id": "[my id as a string]",
"access_token": "[my token as a string]",
"expiration_date": "2015-10-26T07:45:16.579Z"
}
}
}' \
https://api.parse.com/1/users
I've googled around a bit, including reading the following posts, but after changing my settings on my Facebook app multiple times and re-authenticating, it is still throwing the same error.
Using FB user to login on parse. Error code: 251, Invalid Sesion Error
Parse Facebook login fails with error code 251
For the record, I've tried changing my "App Secret embedded in the client" Facebook setting to false, as well as my "Native or desktop app?" to both yes and no (I'm fairly sure it should be set to yes, as I'm using the desktop app FB login flow.) I've also added my facebook app to my parse app, and enabled Facebook integration on parse, as well as double checking my parse app and rest api keys.
Please let me know what else I should try, or what other information you need to assess this.
Two things were wrong with the way I was approaching this.
I was creating the "Expires_at" field by adding the "Expires_in" field (returned using this FB login flow) to the current time as calculated by my browser. In retrospect this was silly, as the expiration time is supposed to be exact, and network latency will change the calculated time by a bit.
I was using the wrong facebook ID for my request - there are two types of IDs now, and you need to use the correct one. See this link..