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

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

Related

I need to get and active users list or active connections who are in chat Bot Framework

I need active users or active connections list who are available to chat, who left from conversation I don't want to retrive those in below code, please help me out on this below is the code of getting all connections list.
var activity = dc.Context.Activity;
IList<ConnectionRequest> connectionRequests =
_messageRouter.RoutingDataManager.GetConnectionRequests();
replyActivity = activity.CreateReply();
if (connectionRequests.Count == 0)
{
replyActivity.Text = "No pending requests";
}
else
{
replyActivity.Attachments = CommandCardFactory.CreateMultipleConnectionRequestCards(
connectionRequests, userService, activity.Recipient?.Name);
}
The way bots built with the Bot Framework work is somewhat different that bots made for a specific service, like a Discord bot or a Slack bot. Since there are a multitude of different channels that you might offer your bot on, some of which don't have the concept of "online users" as such, there is no built-in functionality that gets all online users.
Depending on the channel in which your bot is operating, the concept of "online users" could have different meanings. A Teams bot for example only connects to a new user one time, and persists the conversation, whereas a Direct Line bot does not.
Bots developed with the Bot Framework SDK are inherently stateless, and as such you would need to define and implement your own method for identifying and contacting "online users".
You could for example store the names and user IDs of users who connect to your bot for a period of time. If your users use AAD auth you could make use of Microsoft Graph APIs.
Essentially, there is no standard way to do this, and you would need to define your own custom logic to fit the channel and features of your specific bot.

How to send message to all the members of the group on Installing teams bot

I have created a teams bot and had a service written in .NET core to handle events and user's messages to reply accordingly.
When I install a bot in a group, I need to send personal message(one-to-one i.e between bot and the user) to all the members of that group on installation. I am trying to do that in OnConversationUpdateActivityAsync event handler (which gets fired when I install the bot). But in this event I am getting information of the user who is installing the bot, not the other members which are added in that group, also I am not getting any information of the channel(channelId and members etc.) in which the bot is getting installed.
Any different approach or solution will work.
Thanks in Advance.
You haven't said if you want the bot to message the users privately (like 1-1 between the bot and user) or just send each person a personal message inside the group chat, but in both cases, Proactive Messaging is your correct approach. If you want to send a message inside the group chat itself, see this sample.
If you want to send the users messages directly, 1-1, they need to have the bot installed as a personal app already. It's possible to do this automatically, but it's a bit more work, and requires Microsoft Graph. The proactive messaging is a bit different too - you get the list of members as per the previous sample, but see here for how to get the required 1-1 conversation details, and how to send the actual message. This last link also has documentation on how to get started, and some background reading (at the bottom of the page).
#Hilton is correct, You need to specify in which scope you want to notify user 1:1 or directly in Group chat?
App should be installed in user scope if notifying user on installation, You can proactively install the App in User/Group Chat/ team scope using Graph API. To notify users in Teams or Group chat, You can fetch the list of members using List conversation members API, When you install the App using Graph API Bot received converstionUpdate, You can save the conversationReference and use it for proactively notifying.

Microsoft Azure Bot Service Proactive Messaging to Group (Meeting) Chat

I would like to implement the following Scenario:
Within a Meeting that should take place in the real world in a room (not necessarily within MS Teams), I want a Microsoft Azure Chat bot to post a message to the meeting-chat, without someone having to add the bot to that meeting chat.
I noticed, that real proactive messaging to MS Teams is still not possible, a workaround is necessary: Catching a conversation reference including the users teams-chat-id while he adds the bot e.g. via personal teams app. This works good, if the teams app is pushed to all users within an organization via policies.
This workaround however is not possible within a meeting-chat, that might not exist at the time the bot should write to it. So, no possibility to catch a conversation reference to post to.
Also, I noticed that there does not even exist a MS Graph endpoint neither a connector within Logic apps to post a teams message to several users without cannel-context.
Do you see any workaround for this scenario, or is it simply not supported?
To my knowledge, you're right on both accounts - a bot can't proactively message a chat that it's not part of, and I don't think Graph supports messaging to group chats altogether, which is your scenario.
Just on a point of correctness though, a bot can proactively message (a) individual users (1-1), (b) group chats, and (c) Team channels, each separately (i.e. it does not need to be installed by each user, and message each user privately, unless that is the desired scenario. All that's required for each of these is the relevant "conversationid" that represents the specific conversation, and the ServiceUrl.

Sending context information to chatbot

While launching a web chat bot from a portal (through iframe), is it possible to send the details of the logged in user (who has already logged into the portal) to the bot and save it in the bot state so it can retrieved inside the bot code to do some customization or apply custom logic based on the user details. User details can include their name, date of birth, gender etc.
Your web app and bot can exchange information "behind the scenes" (i.e., invisible to the end-user) by exchanging activities of type event. An activity with type event will not be displayed by clients such as Web Chat, so the end user won't see any evidence of the communication. This type of communication between client and bot is sometimes referred to as the "backchannel mechanism."
For an example of how this is done, check out Ryan Volum's backchannel sample bot.

Can user resume a conversation in a different channel? (Bot Framework)

Let's think of the following example:
1) I have a certain bot deployed on Azure
2) Bot can be talked via Facebook Messenger and via Skype
3) A certain user talks to the bot via Facebook Messenger and then he leaves.
4)A couple of minutes ago the same user resumes the conversation with the bot, but via Skype.
Is this possible? I assume Bot Framework doesn't have anything included for this, hence, that this isn't posible (as conversations are independent and state changes depending on the channel). Is there any way to identify a user (via some authentication method maybe), and then making this logic again?
Do any of you know any workaround for this?
Thanks in advance!
The Bot Framework Connector service is a component which provides a single API for your bot to communicate across multiple client services such as Skype, Email, Slack. Every bot and user has an account within each channel.
The channel account contains an identifier (id) and other informative bot non-structural data, like an optional name.
And there us unique conversation ID created for each conversation of each user for each channel. And you can customize your channel capabilities as described here.
Regards,
Jyo

Resources