Chat Bot Exception for Telegram: Microsoft.Bot.Builder.BotFrameworkAdapter.SendActivitiesAsync
I am getting below error for few functionality. Few are working fine. This error is for Telegram channel only and Facebook Messenger works perfectly. Please let me know why is this happening and how can be fixed.
"Response":{"StatusCode":400,"ReasonPhrase":"Bad Request","Content":"{\r\n \"error\": {\r\n \"code\": \"BadArgument\",\r\n \"message\": \"Invalid Url: \"\r\n }\r\n}"
Stack Trace:
at Microsoft.Bot.Connector.Conversations.ReplyToActivityWithHttpMessagesAsync(String conversationId, String activityId, Activity activity, Dictionary`2 customHeaders, CancellationToken cancellationToken)\r\n at Microsoft.Bot.Connector.ConversationsExtensions.ReplyToActivityAsync(IConversations operations, String conversationId, String activityId, Activity activity, CancellationToken cancellationToken)\r\n at Microsoft.Bot.Builder.BotFrameworkAdapter.SendActivitiesAsync(ITurnContext turnContext, Activity[] activities, CancellationToken cancellationToken)\r\n at Microsoft.Bot.Builder.TurnContext.<>c__DisplayClass29_0.<<SendActivitiesAsync>g__SendActivitiesThroughAdapter|1>d.MoveNext()
Code Sample:
private async Task<DialogTurnResult> GetDevicesAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
var accessor = _userState.CreateProperty<User>(nameof(User));
var user = await accessor.GetAsync(stepContext.Context);
List<Device> devices = stepContext.Values.ContainsKey(Messages.smartcard)? (List<Device>)stepContext.Values[Messages.smartcard]: null;
devices ??= await _viewSubsService.GetSubcriptionAsync(user.Country, Messages.BusinessUnitDstv, (int)user.CustomerNumber);
if(devices == null || devices.Count == 0)
{
await stepContext.Context.SendActivityAsync(MessageFactory.Text(Messages.NoSmartcard));
return await stepContext.EndDialogAsync(null, cancellationToken);
}
else
{
List<CardAction> cardButtons = new List<CardAction>();
foreach (var device in devices)
{
CardAction cardButton = new CardAction
{
Type = ActionTypes.ImBack,
Title = device.SmartcardNumber,
Value = device.SmartcardNumber
};
cardButtons.Add(cardButton);
}
HeroCard heroCard = new HeroCard
{
Title = "Let's get rid of that nasty error",
Subtitle = "",
Text = "Select a smartcard from below",
Images = new List<CardImage> { new CardImage("") },
Buttons = cardButtons
};
var attachment = MessageFactory.Attachment(heroCard.ToAttachment());
attachment.AttachmentLayout = AttachmentLayoutTypes.Carousel;
var options = new PromptOptions() { Prompt = (Activity)attachment };
return await stepContext.PromptAsync(nameof(TextPrompt), options);
}
}
I am using Waterfall step dialog flow.