Telegram channel issue: [400] Bad Request (BUTTON_DATA_INVALID)
Bot Info
- SDK Platform: Node.js
- SDK Version: 3.14.0
- Active Channels: Telegram
- Deployment Environment: Azure App Service (Azure Web App)
Issue Description
Telegram channel fails with following error in console:
Error: POST to 'https://telegram.botframework.com/v3/conversations/370544732/activities/K1CfSzs9lFJ' failed: [400] Bad Request
at Request._callback (D:\home\site\wwwroot\node_modules\botbuilder\lib\bots\ChatConnector.js:559:46)
at Request.self.callback (D:\home\site\wwwroot\node_modules\request\request.js:186:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (D:\home\site\wwwroot\node_modules\request\request.js:1163:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (D:\home\site\wwwroot\node_modules\request\request.js:1085:12)
at IncomingMessage.g (events.js:291:16)
at emitNone (events.js:91:20)
In channel status log I see the following error messages:
{"ok":false,"error_code":400,"description":"Bad Request: BUTTON_DATA_INVALID"}
Code Example
var restify = require('restify');
var builder = require('botbuilder');
// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log('%s listening to %s', server.name, server.url);
});
// Create chat connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
appId: process.env.MicrosoftAppId,
appPassword: process.env.MicrosoftAppPassword
});
// Listen for messages from users
server.post('/api/messages', connector.listen());
var bot = new builder.UniversalBot(connector, [
function (session) {
session.send("Hello!");
builder.Prompts.choice(session, "Please select your choice, clicking the button",
["Button 1", "Button 2"], { listStyle: 3 });
},
function(session, results) {
if (results.response.index == 0) {
session.beginDialog('customDialog');
} else {
session.endDialog();
}
}
]);
bot.on('conversationUpdate', function (message) {
if (message.membersAdded) {
message.membersAdded.forEach(function (identity) {
if (identity.id === message.address.bot.id) {
bot.beginDialog(message.address, '/');
}
});
}
});
Reproduction Steps
- Create bot application in Azure App Service
- Edit app.js and add the code example above
- Create a Telegram bot
- Add and register Telegram channel
- Try to start conversation with
/startcommand
Expected Behavior
Expected Telegram channel to work properly.
Actual Results
When I start a conversation using /start command in Telegram, bot does not respond anything.
Hi,
Any thoughts/updates on this issue? Telegram channel still does not work.
I am unable to replicate this issue, as this appears to be working normally for me. However, I did create a dialog named "customDialog" when I was attempting to replicate this, as I was getting a message saying that dialog wasn't found when I first attempted to run your sample.
Was the code sample the entirety of the code, or did you have other dialogs set up?
I managed to resolve the issue, by recreating Bot Channels Registration object, but eventually I did not get the reason of problem. It is a bit strange since initially everything worked fine.
Has the issue recurred since recreating the Bot Channels Registration object?
Now I am getting this issue only if try to render in Telegram Prompts.choice with large number of buttons (e.g. 30). It seems there is a restriction on it, because of Direct Channel and Web Chat works fine.
I do not appear to be replicating the issue with large numbers of buttons in Telegram, as I am not getting an error when I tested in Telegram with 30 buttons. Did you exceed 30 by any chance?
I have the same issue with telegram channel working from C#. In web Chat/skype channels code work fine. Bot showing first Greeting message and than failing on sending first question
Packages: "Microsoft.Bot.Builder" version="3.14.0.7" targetFramework="net46" "Microsoft.Bot.Builder.Azure" version="3.2.5" targetFramework="net46" "Microsoft.Bot.Builder.History" version="3.14.0.7" targetFramework="net46" "Microsoft.Bot.Connector" version="3.14.0.7" targetFramework="net46" What I see on Azure portal: 3/21/2018, 3:18:07 PM | {"ok":false,"error_code":400,"description":"Bad Request: BUTTON_DATA_INVALID"}
my code:
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable
private async Task Question1Async(IDialogContext context)
{
var m = context.MakeMessage();
m.AddKeyboardCard("Правильно ли я понимаю, что на данный момент Вы уже не работаете в системе XXX?", new[] { NoMoreWorkingInSberbank, StillWorkingInSberbank });
await context.PostAsync(m);
context.Wait(Question1ResponseReceivedAsync);
}
In telegram windows I can see: "POST to igorsber failed: POST to the bot's endpoint failed with HTTP status 500"
In application Insights error looks like:
{
"message": "An error has occurred.",
"exceptionMessage": "Operation returned an invalid status code 'BadRequest'",
"exceptionType": "Microsoft.Bot.Connector.ErrorResponseException",
"stackTrace": " at Microsoft.Bot.Connector.Conversations.1.<Rest>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Builder.Internals.Fibers.Wait2.<Microsoft-Bot-Builder-Internals-Fibers-IWait1.<Microsoft-Bot-Builder-Internals-Fibers-IFrameLoop<C>-PollAsync>d__9.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Builder.Internals.Fibers.Fiber1.<Microsoft-Bot-Builder-Internals-Fibers-IFiberLoop2.Microsoft.Bot.Builder.Internals.Fibers.IAwaiter<T>.GetResult()\r\n at Microsoft.Bot.Builder.Dialogs.Chain.LoopDialog1.1.<Rest>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Builder.Internals.Fibers.Wait2.<Microsoft-Bot-Builder-Internals-Fibers-IWait1.<Microsoft-Bot-Builder-Internals-Fibers-IFrameLoop<C>-PollAsync>d__9.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Builder.Internals.Fibers.Fiber1.<Microsoft-Bot-Builder-Internals-Fibers-IFiberLoop
@SychevIgor have you tried recreating the Bot Connector Registration object? The original requester said that helped initially.
@easkerov I am still investigating the issue regarding the large number of prompt buttons. Also, did the Invalid Button Data 400 error show up again?
@nodeomega I've just tried to reproduce issue again (with number of options 66) and can confirm the error BUTTON_DATA_INVALID with large number of prompt buttons. I've changed list style to listStyle: builder.ListStyle.auto to render prompt as numbered list or buttons automatically depends on array size. In this case when number of items in choice array is large it always render it as numbered list.
@nodeomega yes, I tried. Not helped.
@nodeomega I don't know what was happened, but after some days (and redeploy) telegram starts showing everything right. I didn't change the boot code or any dependencies (styles on a default.html was a reason to redeploy)
@easkerov I have not been able to repro the BUTTON_DATA_INVALID message you are getting, even when I set it to listStyle: 3. (this sets it to use buttons always) I used 67 choices for the prompt as well with this data:
// Test data: 1980's (mostly) cartoon character names.
var promptButtons = ["Megatron", "Starscream", "Soundwave", "Skywarp", "Thundercracker", "Rumble", "Ravage", "Laserbeak", "Frenzy", "Astrotrain",
"Devestator", "Menesor", "Bruticus", "Predaking", "Octane", "Galvatron", "Cyclonus", "Scourge", "Scorpinok", "Ramjet",
"Trypticon", "Sideways", "Barricade", "Shockwave", "Nemesis Prime", "Optimus Prime", "Bumblebee", "Ironhide", "Ratchet", "Blaster",
"Cliffjumper", "Superion", "Computron", "Grimlock", "Slag", "Swoop", "Hot Rod", "Rodimus Prime", "Metroplex", "Omega Supreme",
"Unicron", "Primus", "Cobra Commander", "Optimus Primal", "Duke", "Lady Jaye", "He-Man", "She-Ra", "Orko", "Man-At-Arms",
"Lion-O", "Cheetara", "Tigra", "Panthro", "Snarf", "Jaga", "Mumm-Ra", "Jem", "Skeletor", "Evil-Lyn",
"Hordak", "Stinkor", "Hulk", "Thor", "Iron Man", "Black Widow", "Loki"];
var bot = new builder.UniversalBot(connector, [
function (session) {
session.send("Hello!");
builder.Prompts.choice(session, "Please select your choice, clicking the button",
promptButtons, { listStyle: builder.ListStyle.auto });
},
// ........ more code follows
Now with builder.ListStyle.auto, yes, I am seeing it does a numbered list instead with the large amount of choices in "Test in Web Chat", but it rendered as buttons in my Telegram client. (Windows 10, Telegram Desktop 1.2.17) - Is this the version of Telegram you are using? If not, what Telegram version and platform are you running?
@SychevIgor There has been an updated deployment of our Telegram channel within the last week or two, perhaps that might have accounted for the showing everything right now. Is everything alright now or are we still seeing an issue?
@easkerov on my side- everything works fine.
@nodeomega I am using Telegram 3.8.2.119501 on macOS (High Sierra) and Telegram X on Android. I will try to check on Windows desktop client.
@easkerov Telegram on MacOS does have a couple issues that we are aware of, and that I have made the Telegram team aware of as well (such as repeating prompt choices). I'm still awaiting feedback from the Telegram team on the issue request I have opened with them a few weeks ago.
Using another version of Telegram such as Windows desktop is recommended at this time.
I am closing this issue as it has been inactive for an extended period. If this issue persists or recurs, feel free to open a new support request. Thank you.
@nisha1142 This repository you are posting to is for the Microsoft BotBuilder library. Telegram happens to be one of the channels we support in terms of bots using BotBuilder framework on said channel. Mr. Pavel Durov of Telegram does not have any bearing on this repository.