Facebook API send element_share payload? - node.js

I'm building a Node.js ChatBot with Wit.ai on Messenger and I just want to know if it's possible to track user action when they open The Share part on Messenger.
"recipient":{
"id":"USER_ID"
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"generic",
"elements":[
{
"title":"Breaking News: Record Thunderstorms",
"subtitle":"The local area is due for record thunderstorms over the weekend.",
"image_url":"https://thechangreport.com/img/lightning.png",
"buttons":[
{
"type":"element_share"
}
]
}
]
}
}
}
There is no post back, no payload send to the ChatBot so How can I achieve this please ?

There is not a way in the Messenger api currently to detect users sharing an item.
You could load the share url with parameters to identify the user, and listen for them on your server when loading the page. That could help attribute shares to users.
There is also the Messenger Extensions sdk which can get the page scoped id of a user on your site.

Related

How to display welcome message in dialogflow when a user opens the bot and display custom payload in chat web demo?

I am trying to design a chatbot for my company. In my company we mainly build applications for the bank sector. I was asked to design a bot for one of our clients. The plateform I am using to do it is dialogflow. I have finished the first step of my application but I have somes problems.
We want to integrate this bot in Whatssap messenger.
The first question is that how can I enable a welcome message whenever a user opens the chat in whatssap ? is it possible to do it ?
**The Second problem is : When I add a Custom payload json data, the payload dont gets displayed whenever I try to use the web demo functionality to interact with my bot. How can I solve this problem ?.
the custom payload I have added is :
"richContent": [
[
{
"options": [
{
"text": "Effectuer un virement."
},
{
"text": "consulter solde."
},
{
"text": "procéder à une ouverture de compte."
}
],
"type": "chips"
}
]
]
}```**
All the informations get displayed in the bot except the payload I have added. Is there anyway to solve this problem ?

Google Dialogflow Quick Replies formatting issues in Telegram

I had create a chatbot using Dialogflow and integrated it with Facebook Messenger & Telegram. I noticed that for the Quick Replies in Telegram (Link 1) appears differently in FB Messenger (Link 2). Is there any way to make it nicer and more presentable in Telegram?
Telegram
Facebook Messenger
This is my Quick Replies settings in Dialogflow.
Dialogflow
in DialogFlow you can indeed (as Marc pointed out) use a Custom Payload for Telegram, here it is an example:
{
"telegram": {
"text": "What would you like help with?",
"reply_markup": {
"inline_keyboard": [
[
{
"text": "Daily News",
"callback_data": "news"
}
],
[
{
"text": "New Features",
"callback_data": "features"
}
]
]
}
}
}
The quick replies appear a buttons you can click (notice the actual response is sent but not displayed within the chat).
All the best!
Beppe
SHORT ANSWER:
That is NOT possible.
DETAILED ANSWER:
Each Channel (Facebook Messenger, Telegram etc.) has its own UI components and its own styling. Those can't be changed as they are rendered/controlled by the channel it self.
What Dialogflow doing is giving you the ability to show these UI components in each channel without making you handle the different implementation needed for each channel.
Dialogflow also gives you the ability to send Custom Payloads where you can send a custom JSON (that should be compatible with the channel you are connected to) That can be used if the channel for example has a UI component that is not yet supported by Dialogflow.
If the channel gives you an option to change a property in the UI components you are using, you could do that using Custom JSON, But still you are always limited to how each channel renders the UI components and what features they provide us

Dialogflow Web Integration not showing Quick Replies and Multiple Replies

I've created a chatbot using Dialogflow and integrated it with Telegram, Facebook Messenger and Web.
The response for Dialogflow is created via Fulfillment written in Python.
In Telegram and Facebook Messenger I am getting replies as expected for each message from user.
But now when I am trying integration for Web, I've noticed that the replies from chatbot does not show multiple reply messages/lines and Quick Replies.
Below is screenshot when user say 'Hi' to the chat bot in Telegram, Facebook Messenger, Web and Dialogflow console respectively. Why is this happening and how can I fix this?
Below is the Fulfillment response JSON:
{
"fulfillmentMessages": [
{
"text": {
"text": [
"Greetings from Tulsi Village!!!",
"My name is Appu. I am your virtual assistant.",
"How can I help you?"
]
}
},
{
"quickReplies": {
"quickReplies": [
"Book",
"Rooms",
"Contact",
"Other"
]
}
}
]
}
The rendering of response depends on the client you are using.
Telegram, Facebook Messenger, are able to render the quick-replies and multi-line replies.
But the web-demo which you are using does not support these, hence you are not able to see quick-replies and multi-line replies.
If you want to integrate it with a website, you need to design it in such a way that it can render the json response and show it correctly. Web-demo is not designed to render these.

Posting on facebook via unificationengine

Hi I'd like to post to facebook via unification engine. I've already created a user, added and tested successfully a facebook connection, but when I post I get the following response:
{"Status":{"facebook":{"status":190,"info":"Error validating access token: Session does not match current stored session. This may be because the user changed the password since the time the session was created or Facebook has changed the session for security reasons.: "}},"URIs":[]}
When I use the facebook token, that was used for creating the connection, to post to facebook directly (without unificationengine), then it works just fine. What might be the problem here? Status 190 is neither documented on facebook nor on unificationengine.
#unificatinengine developers: it would be practical, if the errors returned by the service would be passed on inside the unificationengine response, this way debugging such errors would be easier, and the errors could also be processed programmatically.
Additional info
Today I seem not to be able to reproduce the response of yesterday. The postfields I use to post the message to facebook (the same as yesterday) are as follows:
{
"message":{
"receivers":[
{
"name":"me",
"address":"https://graph.facebook.com/v2.1/me/feed",
"Connector":"facebook"
}
],
"sender":{
"address":"sender address"
},
"subject":"test",
"parts":[
{
"id":"0",
"contentType":"text/plain",
"type":"body",
"size":25,
"data":"this is the plain message"
},
{
"id":"1",
"contentType":"text/html",
"type":"body",
"size":42,
"data":"<div>this is the <b>html</b> message</div>"
},
{
"id":"2",
"contentType":"text/plain",
"type":"link",
"size":17,
"data":"http://www.web.de"
},
{
"id":"3",
"contentType":"text/plain",
"type":"link_description",
"size":21,
"data":"some link description"
},
{
"id":"4",
"contentType":"text/plain",
"type":"link_title",
"size":10,
"data":"link title"
}
]
}
}
But today I get the following message back from unificationengine
{
"Status":{
"facebook":{
"status":100,
"info":"Unsupported post request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api: "
}
},
"URIs":[]
}
Unfortunately this does not tell me, what unificationengine does internally for posting to facebook (which should not concern me), and what goes wrong there.
Does the "/v2/connection/info" show the details of the facebook connection that you have added? If not can you please update the connection with a new access token, using the same connection identifier for the "v2/connection/add" api endpoint, and check if it works.
unificationengine

Slack API, get current location

Is there any method to get current user location. Let say I created some "slash" command /map. When I am calling this command - POST message being send to my nodejs server, and server returns some json data.
{
"channel": "#map",
"username": "test",
"unfurl_links": true,
"icon_emoji": ":world_map:",
"attachments": [
{
"fallback": "Required plain-text summary of the attachment.",
"pretext": "Beautiful Personalized Map Sharing",
"image_url": "http://static.mapjam.com/yrjkbmb/auto/640x480.jpg",
"thumb_url": "http://static.mapjam.com/yrjkbmb/auto/640x480.jpg"
}
]
}
Because I am authenticated I am able to get some Slack user info:
username
email etc..
How can I access Slack user lat, long if it is possible though
Currently there is nothing available in the user info to get the geographical position of a user from the Slack API.
Please refer to the Users Info Slack API documentation and the User Type documentation.
If you are expecting to create a slash command the slack application would have to have permissions to your devices location. Looking at the permissions on my android app id does not request permissions to the devices location.
Just spit-balling, there could be a way to do it. This is completely hypothetical simplified method. You would have to have a helper application on the device that has permissions to the location of the device. That app would listen for the /location /map request then post to the channel where the request came from.

Resources