Can I start the conversation with messenger bot? - bots

My bot is running in perfect conditions when I use it trought funpage.
But what I want to know is if we can start the conversation with the user instead user with it.
For example: The user is on a page that his next interation is talk with my BOT. But i don´t want my clients start I want my bot starts.
At this case we can consider that user already authorized my app.

Not if this is their first messenger interaction with you.
When you message a user, you're sending a message to a user id that is page scoped.
So unless they've previously messaged your page, there's no way for you to get their id
The id must be an ID that was retrieved through the Messenger entry points or through the Messenger webhooks (e.g., a person may discover your business in Messenger and start a conversation from there.
These IDs are page-scoped IDs (PSID). This means that the IDs are unique for a given page.
If you have an existing Facebook Login integration, user IDs are app-scoped and will not work with the Messenger platform.
(see https://developers.facebook.com/docs/messenger-platform/send-api-reference)

Related

Microsoft Bot Framework: How to add Bot to chat via messaging extension?

Let's assume a user chats with another user in a 1:1 chat. (Might also be a group chat.) The user adds a bot and continues to chat while the bot now adds value to the conversation.
We are searching for a way to make adding the bot to a chat as seamless as possible through a simple button click. It seems the closest we can get to a button is using a messaging extension action command.
When the user invokes the messaging extension our backend service runs and can respond e.g. with a card. Now instead of a card is it possible to generate a response to add a bot? There are special responses e.g. for authentication. Is there a response telling the Teams client to add a bot?
Any hints are appreciated.
JIT installation of bot is an option here. You will be able to add bot to user conversation. Check following sample application which helps to add bot instantly: https://github.com/SubbaReddi/89.teams-just-in-time-installation

DialogFlow Manual Handover to Facebook Messenger

I've successfully setup a DialogFlow bot which integrates with Facebook Messenger.
Is it possible for a human user to log into the Facebook Messenger inbox and take manual control over the conversation?
When I log into the Facebook Messenger inbox I've been unable to stop the bot from replying to the user and as a result it ends up being a 3 way conversation between me, the user and the bot.
This usecases makes sense but is not well documented. Facebook mentions this in the handover protocol documentation:
Taking Thread Control From Facebook Page Inbox
For Messenger experiences that enable live chat via Facebook Page Inbox, the handover protocol allows the Page admin to manually initiate a take thread control event by moving the conversation from 'Done' to the 'Inbox'. It is important to note that the thread would immediately be passed to Facebook Page Inbox irrespective of the current app’s role.
I guess this is what you need.
What you need to do is this:
Find the conversation you want to manual control
Check 'Move to Done'
FInd the conversation again by adding the 'done'-filter
Click the Move to Main button (the envelop in the top right
corner)
Remove the 'done' filter to find the conversation
from now on, the inbox has control and your chatbot will not respond if the user types a message. You will be the only one responding
If you need the chatbot to manage the conversation again, just click on the Move to Done-checkmark and the chatbot has control again.
Ps: the documentation also suggests you to subscribe to two webhooks (Standby and messaging-handovers). To be honest: for me it worked with and without subscribing to these webhooks

Retrieve Teams User ID based on AAD ID

I am trying to start a scheduled proactive conversation (the bot initiates the conversation on scheduled time).
I managed to get the User's AAD ID based on Graph API, but it doesn't match the Teams user ID. Tried for over 2 hours to obtain the right id, but I can't figure it out how. What would be the best approach I should take?
Have a look at the Microsoft Graph api to get the chat thread ID.
When the app is installed for the user, the bot will get receive a conversationUpdate event that will contain the necessary information for it to send the proactive message. For more information, see Bot events.
If you lose the chatThreadId, you can find it again by calling:
GET /users/{user-id}/chats?$filter=installedApps/any(a:a/teamsApp/id eq '{teamsAppid}')
However, this will only for for the personal scope! My advice would be to make sure you catch the conversationUpdate which is triggered after an install and persist the user details in a database.
I'm curious how you tried to "match" these? In any case, I don't think they're intended to match up in any way (the aadObjectId Guid and the "29:..." user id). As a result, you should store a mapping on your side (database or similar). You need to store ServiceUrl and ConversationId anyway to do proactive messaging, so just tack userid on as well.

How do I know Slack bot's user_id?

I'm making a slack bot (A) that responses to a message from another slack bot (incoming-webhook) (B).
I'd like to know the user_id of B so that its message will be a trigger for A, where I have some problem getting it.
I tried users.list method (https://slack.com/api/users.list?token=blabla) but the B didn't appear in a result.
Do you have an idea about what method to take to know the user_id of B?
Incoming webhooks appear as apps, not as bot users on Slack. So you won't find a bot user ID in the user list as you would for normal bot users.
Apps have a bot ID, but unfortunately there is no official API method to get the list of bots / apps in a workspace. But if you have control over a workspace and can generate a legacy token you can use the unofficial API method bots.list.
There also is the official bots.info method, if you already have the bot ID and just want to know which app it belongs to.
To create a legacy token for your workspace make sure you are logged in and then go to this page.

Rooms vs Namespaces for a Chat Widget with Admin Dashboard

I'm building a chat widget using Facebook Messenger (similar to Intercom live chat or Tawkto or Drift). However, since it's powered by Facebook Messenger user send messages from their Facebook id. The Facebook id of a user will be like pageID_userID (since facebook gives a page scoped user id)
The admin will have a dashboard where he can manage multiple pages and its messages. How can I implement rooms/namespaces in this scenario?
My thoughts: End-user(pageID_userID) subscribes to a room named 'pageID_userID'. When he sends a message, it will be also sent to a room named 'pageID'. And admin opening the dashboard joins to N rooms. Where N is the number of pages he manages.

Resources