question

KewalSarode-4030 avatar image
0 Votes"
KewalSarode-4030 asked KewalSarode-4030 commented

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.


azure-bot-service
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello,

Could you please share any code sample you are referring to?

Regards,
Yutong

0 Votes 0 ·

Sample code added in the question. Sorry for delayed response

0 Votes 0 ·

0 Answers