I have a working Facebook messenger bot.
From the Messenger app, I would like my bot to trigger the “camera” action (to snap a new picture or video) for the user.
To clarify with a hypothetical context, I would create persistent menu action which mimics the behavior of clicking the “camera” button under the message text area.
I looked into the “Page Call To Action” operation of the Graph Api but could not find parameters that would produce the desired behavior.
3
Answers
I’m pretty sure there is no way to do what you want, right now. Hopefully, in the future, the Messenger team will add more features like this to bots.
Here is the solution to your problem.
In Facebook Messenger, you can open a webview and load a webpage. But remeber that good old HTML 5 provides us with a simple way of asking the user to use their camera when they are on mobile.
These steps below work today
You can use a url button to open a webview as such
“buttons”:[
{
“type”:”web_url”,
“url”:”https://url_to_your_webpage“,
“title”:”View Item”,
“webview_height_ratio”: “compact”
}
]
In your webpage, include this HTML5 element that allows user to take image via camera on mobile
<input type="file" accept="image/*" capture="camera" />
Submit the image to your servers, close the webview, and do any processing required. For example you can now send the image back to the user from your bot.
You can simply send a message to the user to click on the camera icon, click the picture and send it to the bot. You can then receive that image as the attachment -> read ‘Message with image attachment’ and reply to the user. This will be more of the native experience. In webview the user can deny permission to the camera (if asked for). Hope this helps!