-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question Bot C#]How to stop sending multiple messages in the beginning to activate itself #2941
Comments
Change the following line: For more details, see @dandriscoll reply here: #2093 (comment) :
|
As pointed out by nrobert, ConversationUpdate is sent once for the bot, and once for the user. I'm closing this issue, since the question has been answered. |
Yes but I still get two replays instead of one. Before I changed if (update.MembersAdded.Any()) with [LuisIntent("MainMenu")]
public async Task MainMenu(IDialogContext context, LuisResult result)
{
var tb = result.Query;
await context.PostAsync(WELCOME);
var reply = context.MakeMessage();
reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
reply.Attachments = new List<Microsoft.Bot.Connector.Attachment>();
List<string> lst = new List<string>();
lst.Add("Let's Start!");
reply.AddHeroCard(
string.Empty,
lst
);
await context.PostAsync(reply);
context.Wait(Start); //here it needs to go to Start, but again it returns the code above and the next time goes to Start
} |
This question should be on StackOverflow with more code details as it seems to be an error in your implementation, not a bug in the framework |
This is basically the same thing @nrobert already said, but this is the code I have been using to send welcome messages correctly: else if (message.Type == ActivityTypes.ConversationUpdate)
{
// Handle conversation state changes, like members being added and removed
// Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
// Not available in all channels
IConversationUpdateActivity iConversationUpdated = message as IConversationUpdateActivity;
if (iConversationUpdated != null)
{
ConnectorClient connector = new ConnectorClient(new System.Uri(message.ServiceUrl));
foreach (var member in iConversationUpdated.MembersAdded ?? System.Array.Empty<ChannelAccount>())
{
// if the bot is added, then
if (member.Id == iConversationUpdated.Recipient.Id)
{
//Do the stuff you want to do here
await connector.Conversations.ReplyToActivityAsync(reply);
}
}
}
} |
I'm trying to activate the main root dialog on the conversation update method, my idea is to call main root dialog when the user opens the chat bot, something like proactive bot but not to send welcome message but to activate the root dialog. I've tried this, it works but it sends multiple times the same message to main root:
IConversationUpdateActivity update = activity;
The text was updated successfully, but these errors were encountered: