I want to build a Teams bot that can send proactive messages, including creating conversations even if the user has never had a conversation with the bot.
I followed the proactive sample and adapted it to send a notification as POST in the notify controller. I am able to continue a conversation, but when I try to create one, the user does not get any messages.
Here is my code to create a conversation from the notify controller:
// I got the following 4 values logging them on the bot in a conversation started by a user
const string botAppId = "<MicrosoftApptId GUID>";
const string serviceUrl = "<my service URL>";
const string tenantId = "<my tenant ID>";
const string recipientId = "<recipient ID xy:GUID>";
var title = "test title";
var activity = Activity.CreateMessageActivity();
activity.Type = ActivityTypes.Message;
activity.Text = "test message";
await ((BotAdapter)_adapter).CreateConversationAsync(
botAppId: botAppId,
channelId: Microsoft.Bot.Connector.Channels.Msteams,
serviceUrl: serviceUrl,
audience: null,
conversationParameters: new ConversationParameters
{
Activity = (Activity)activity,
Bot = new ChannelAccount(botAppId),
IsGroup = false,
Members = new List<ChannelAccount> { new ChannelAccount(recipientId) },
TopicName = title,
TenantId = tenantId
},
callback: (turnContext, cancellationToken) => Task.CompletedTask,
cancellationToken: default(CancellationToken));
What am I doing wrong here? Am I missing things in the conversation parameters? Should I populate the audience? How?
Thanks for any help!
Note that this is a new post based on my comment on https://stackoverflow.com/a/60024372/1322336