How to map a Watson Assistant conversation to a user of my application? - ibm-cloud

I integrated a Watson Assistant to my Website. To access the assistant, a user needs to log in. Now in my frontend, I know who my user is. When the user goes to the page with the watson assistant, I want to store some information of the conversation my user had with the chatbot. In my frontend I create the chatbot by including a provided script link.
When retrieving all Logs of the chatbot, I get all the conversations with conversation_ids and user_ids generated by IBM.
How do I map those IBM-generated ids to my application user-ids?
Can I somehow pass my application user_id to watson when opening the chatbot, so I can use Webhooks to post the conversation_id and my application user_id to the backend and save it there?
Or is there another way to do that? What are best practices on how to do that?
Or do I have to start conversations in a programmatic way, like described here?

The best way to send the user id to Watson Assistant is by using https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-instance-methods#updateuserid
You can then use pre or post message webhook to send to your backend your conversation_id and the user_id.
The user_id you have set via the above method will appear in context.global.system.user_id.
More info can be found at: https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-web-chat-develop-userid

Related

facebook application for login and messenger same ids?

I am building a facebook messenger bot. And the bot is giving user ids. But it is not clear to me if the messenger ids are the same ids that would be returned if I use the same app and add to it a login feature. Because we already have an app and has a login feature, now we need to build a facebook bot and identify the already existing users in our db that are using the bot.
I have read facebook tutorial about linking 2 different applications to the same business to get consistent ids. But what if I use that same application to login users AND for messengers (by using the add products to the application, and so having one application, one app id) would that work? Would I be getting the same user ids?
PS: I would test myself but I am in an awkward position where the page/database/login app owner is a different person, and they are not big on sharing data, and I am supposed to blindly write a messenger code that is supposed to work when they deploy it.
All help is appreciated, thank you.
You need to use Facebook's ID Matching APIs for this purpose:
Here is the details: https://developers.facebook.com/docs/messenger-platform/identity/id-matching

How can I show a dynamic welcome message using Amazon lex bot?

I am developing a chatbot using Amazon lex. It is going to be integrated with facebook messenger in a facebook page. When a user opens the bot for the first time, it says nothing. It listens to user intents. I would like the bot to initiate a conversation and provide the user with a few options(configured in a mysql database in the backend). What is the best way to do this?
There is a get_started event which you can subscribe to with FB Messenger
See the Docs
When triggered, hit your db to get whatever response is appropriate based on the context you have from the event, and anything in your DB.

Facebook Messenger Platform: how to get user specific information?

I'm trying the recent released Facebook Messenger Platform and so far so good. Everything worked well and I was able to create a echo bot.
But I'm wondering how I could identify this user that started chatting in my page. For example, when a user started chatting I get a PID user (page specific user id).
Making the follow request to Facebook Graph API:
GET https://graph.facebook.com/v2.6/{PAGE_SPECIFIC_USER_ID}
I discovered that I can just ask for the following fields: first_name,last_name and profile_pic.
So my question is, how could I discover if this user is a current customer of my business page? Is there another way of querying more information (like e-mail and real facebook user id)?
Facebook has updated the messenger platform API (2016-07-01) and introduced a new feature called Account Linking. This can be used to identify a user who has created an account on your website via Facebook Login and you can link the two accounts. Facebook login has its own set of permissions which can be used to get a lot more information via Facebook graph API. You can find the complete list here.
Currently, there's no way to do this. The best way would be to prompt the user to enter their information in chat or give them a link to a mobile login page or some other way of linking their account to the chat.
Messenger Platform 2.0 introduce "ID Matching API" ,that will solve the problem.
https://developers.facebook.com/docs/messenger-platform/connecting-accounts
you can retreive a user information like below using fbmq library https://github.com/conbus/fbmq
# this method will occur when a message received from user
#page.handle_message
def message_handler(event):
user_profile = page.get_user_profile(event.sender_id)
print(user_profile) #first_name, last_name, profile_pic, gender ...

Bot read from my api endpoint

I am creating a bot on facebook messenger, following the tutorial here
Is there a way for the bot to retrieve results from my own api endpoint?
Essentially, I have set up an api endpoint from which results in json is to be returned. I would like the results to populate the template in facebook messenger, like how the current CNN messenger bot shows news based on queries
How do I do this?
Your bot can do anything you want from him. But you have to setup him first on your server...
What he will return, or his behaviour is up to you.
You can use PHP with my API: https://github.com/Fritak/messenger-platform
Just follow an example and then return generic template.
You can use API.ai to create chatbots on Facebook messenger pretty easily. Full disclosure = yes I work there. We've had great feedback on our FB Messenger integration as well as Slack, Kik, Telegram, Twilio SMS, etc. https://docs.api.ai/docs/facebook-integration

How to access Game state on Google Cloud with Facebook ID?

I am trying to access game state from Google server of a Facebook friend. I fetch the List of Facebook friends from Facebook SDK and get a Facebook-id of a friend in return. Game state is present on Google server against Google-id. How can I form a mapping between these two? I want to achieve this without involving any other server.
To dTo get this right you need involving other server.
Although you can do is create a list in a local file, with the relation google user - Id facebook