1

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.

2 Answers 2

1

Use CreateReplyMessage to create a Message object:

var replyMessage =  incomingMessage.CreateReplyMessage("Yo, I heard you.");

Then set the ChannelData

replyMessage.ChannelData = {custom Telegram JSON}
Sign up to request clarification or add additional context in comments.

2 Comments

@DenisovJr. hi, do you have sample code to send keyboard?
See the Telegram Keyboard docs: core.telegram.org/bots/api#keyboardbutton
1

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);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.