Add members to an existing conversation - botframework

(New to Bot Framework)(Using botbuilder SDK4) I have a requirement of passing the control to an agent in case the bot does not recognise the intent of the phrase entered by the customer. I want to connect the customer and the agent using the bot. In my current attempt to achieve this, I am using adapter.continueConversation(conversationReference, logic)
But then I realised, there is an entity called members in the conversation (there exists a method getConversationMembers in botframework-connector/lib/connectorApi/operations/conversations.d.ts).
Question 1: Can I use this attribute for the aforementioned use case?
Question 2: How to add multiple members in a conversation?

Creating a custom middleware is the most efficient way to handover a conversation from the bot to an agent. Here is an example of a bot that implements middleware to forward messages between users and agents with proactive messages. The example uses an array based handover provider to save the state of every conversation. You should implement your own provider with a database structure to fit your project requirements.
Hope this helps.

Related

Can I create a configuration page for a Teams bot app?

I'm building my first Teams app which will have two primary functions:
Proactively send a message to the channel (the bot is installed into) when a specific event occurs on my backend.
Members of the channel reacts to the message via actions.
I finally have a pretty good idea of how to set this up (I think) - but one part I'm missing is that in order to identify the specific app installation as belonging to one of my customers, I need to be able to allow the installing user to supply extra information like e.g. an API-key so that I can associate the specific channel with my specific customer.
Is there any way of doing this with a bot app? I've found examples for creating a configuration page, but they all seem to be associated with tab apps?
I could of cource have the bot ask the user for the information - but maybe there's a "cleaner" way?
Any examples or tutorials would be greatly appreciated as I find it rather hard to get stuff working using Microsoft's own examples etc. :)
Thanks a lot!
When you receive any message from the user, either by typing to your bot, or even installing it into a channel, group chat, or personal context (where you get the conversationUpdate event), you are able to get specific details off of the activity object. If the user sends a message, for instance, then the text property on the activity object will have a value. Incidentally, this is the same activity you will use to get the conversation details you need for the Proactive message.
With regards your question, the activity class also includes a tenantId property, hanging off the conversation property. This is the unique Microsoft 365 Id for the tenant, which would be what I'd suggest to uniquely identify them for your API, or licensing, or similar.

How to store user conversation of Root bot and skill bot on Bot framework SDK V4 built in Visual Studio?

I have build a Handoff bot using Tompanna Sample intermediator bot sample https://github.com/tompaana/intermediator-bot-sample as a root bot and connected it to a dailog Skill, We followed https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/81.skills-skilldialog this sample.
Now I am trying to store user conversation, to do that I followed this https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-howto-v4-storage?view=azure-bot-service-4.0&tabs=csharp article however it only stores the conversation of the root bot. I want to store the conversation of both the bot root and skill.
Can anyone guide me to store the conversation?
Could Application insight also be used to store the log conversations?
Thanks in Advance!!
In your question it contain only for bot storage document but you need to maintain bot state for each conversation. So if you want to store the bot conversation then you need to implement state management in bot flow.
The state and storage features of the Bot Framework SDK allow you to
add state to your bot. Bots use state management and storage objects
to manage and persist state. The state manager provides an abstraction
layer that lets you access state properties using property accessors,
independent of the type of underlying storage.
User state is available in any turn that the bot is conversing with that user on that channel, regardless of the conversation.
Conversation state is available in any turn in a specific conversation, regardless of user (i.e. group conversations)
If you want, you can additionally store conversation flow in Application insight as a custom event using TelemetryClient like trace,metrics,etc.
Reference :
Save user and conversation data
Managing state
Application Insights API for custom events and metrics

How to get the information about all groupChats in which my bot is part of. MsBot framework for Teams (nodejs)

When someone add my bot to their groupchat I am receiving a ConversationUpdate event and I am storing it for future reference. But storing all conversationUpdate events(which I will get when someone add my bot to their chat) of all groupChats has become a problematic. Is their any function for getting the Information about all groupChats that my bot has added to. Like we have a function for listing all Teams channels ex:- TeamsInfo.getChannels(context)
I would be thankful for any help
I'm not aware of any way to do this - the best I could suggest is something like listing conversation members of existing chats, on the graph beta endpoint (https://learn.microsoft.com/en-us/graph/api/conversationmember-list?view=graph-rest-beta&tabs=http). However, that would mean (a) it needs to returns bots as members of the chat, which I'm not sure it does (b) you'd need to basically query EVERY possible group chat in the organisation and (c) you'd need access rights to do that (e.g. application access). So, it certainly sounds like just storing the conversation id upfront on your own would be a better bet.
Recall that you can get the conversation id (if that's what you're looking for) from any event, not just conversationUpdate - even a regular message to your bot from a user in the chat will have the conversation id attached. Also, you've haven't stated what you need the conversation id for. Presumably it's for pro-active messaging, but in that case remember to store the service url as well.

How can I add a middleware logger to my bot?

I tried to add telemetry services following this tutorial, but I looked at my logs in azure and I didn't see user messages. How can I add a middleware that can save user's conversations?
What I'm trying to do is to capture the messages that LUIS and QnA could not find an answer for. So we want to log these so we can improve our bot in the future.
I know LUIS has this feature already in luis.ai, but we want to add more information than what LUIS captures.
You have to do a custom implementation for storing user conversations. I have used Azure Table in one of my implementations to store the conversation. The table structure will have the conversation id + user id as the unique key and then storing the conversation in json format in the table. The conversation data is updated by intercepting every message sent to and from the bot. You can refer this MSDN article for a reference implementation.

How do I correlate user between channels?

From what I see, Bot Framework is providing an abstraction over users in different channels by providing a ChannelAccount class that has ChannelId/Address pair to identify user via its account and Id property, which is... okay, here's the question.
I suppose that the idea behind Id is to provide a unique and persistent identifier that can be used to cross-correlate users between account (i.e., I can say that Slack user #alpha is also email user alpha#company.con). This idea is supported by the fact that ChannelAccount for my bot always has same Id regardless of the channel (and Address is different between channels, obviously).
If this is right, and I hope it is, is there any way to provide BotConnector with the correlation information? I.e., I want BotConnector to give me ChannelId/Address, and I'd give back user Id which I'd the get back in incoming message.
The purpose of this is quite simple: I want the code inside my bot to use the Id as already correlated identifier so that I can log it, build logic from it and so on.
BotFramework does not yet support linking of accounts. In the interim, take a look at this post for one way you might implement a solution:
Why isn't BotUserData persisting and retrievable in my Bot Framework bot?

Resources