Reputation: 95
As far as i know, i can youse Actions (http://blog.botframework.com/2016/05/13/BotFramework.buttons/) to create inline keyboards in Telegram and other messages. But what about Custom Keyboards (https://core.telegram.org/bots#keyboards)? How can i add them using Bot Framework?
I read about ChannelData (http://docs.botframework.com/connector/custom-channeldata/#custom-telegram-messages), but i didnt get, how can i pass JSON to CreateReplyMessage method.
Upvotes: 1
Views: 1215
Reputation: 2525
For Bot Framework v4:
{
var reply = context.Context.Activity.CreateReply(messageText);
if (BotDialogHelpers.ExtractMessengerFromDialogContext(context) == BotDialogHelpers.Messengers.Telegram)
{
GenerateReplyMarkupForTelegram(reply);
}
await context.Context.SendActivityAsync(reply, token);
}
/// <summary>
/// https://learn.microsoft.com/en-us/azure/bot-service/dotnet/bot-builder-dotnet-channeldata?view=azure-bot-service-3.0
/// https://core.telegram.org/bots/api#message sendMessage reply_markup
/// </summary>
private void GenerateReplyMarkupForTelegram(IActivity reply)
{
var replyMarkup = new
{
reply_markup = new
{
remove_keyboard = true,
}
};
var channelData = new
{
method = "sendMessage",
parameters = replyMarkup,
};
reply.ChannelData = JObject.FromObject(channelData);
}
Upvotes: 1
Reputation: 10573
Use CreateReplyMessage to create a Message object:
var replyMessage = incomingMessage.CreateReplyMessage("Yo, I heard you.");
Then set the ChannelData
replyMessage.ChannelData = {custom Telegram JSON}
Upvotes: 1