I am Adding a videos card to my chat bot.
var resultMessage = context.MakeMessage();
var bytes = System.IO.File.ReadAllBytes(HttpContext.Current.Server.MapPath("~/Videos/Cute.mp4"));
string videoData = Convert.ToBase64String(bytes);
resultMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel;
resultMessage.Attachments = new List<Microsoft.Bot.Connector.Attachment>();
VideoCard vc = new VideoCard()
{
// Title = $"hi",
// Subtitle = Address,
Media = new List<MediaUrl>()
{
new MediaUrl()
{
// Url = "https://i1.wp.com/thefreshimages.com/wp-content/uploads/2017/12/lord-shiva-hd-images.jpg?resize=3840%2C2160&ssl=1"
Url = "data:video/mp4;base64,"+ videoData
},
}
};
resultMessage.Attachments.Add(vc.ToAttachment());
await context.PostAsync(resultMessage);
It will play When user click the play button .But I want to play automatically.
Says here that Autostart property is true by default, so it should start playing automatically. You could try setting it to true and see if it works.
VideoCard vc = new VideoCard()
{
Media = new List<MediaUrl>()
{
new MediaUrl()
{
// Url = "https://i1.wp.com/thefreshimages.com/wp-content/uploads/2017/12/lord-shiva-hd-images.jpg?resize=3840%2C2160&ssl=1"
Url = "data:video/mp4;base64,"+ videoData
}
},
Autostart = true
};
Related
When calling GitHttpClient.CreateAnnotatedTagAsync, I keep getting "VS30063: You are not authorized to access https://dev.azure.com" even though my credentials are valid.
This is my code:
var vssConnection = new VssConnection(new Uri("ORG_URI"), new VssBasicCredential(string.Empty, "PAT"));
var gitClient = vssConnection.GetClient<GitHttpClient>();
var tag = new GitAnnotatedTag
{
Name = "tagname",
Message = "A new tag",
TaggedBy = new GitUserDate
{
Name = "Name",
Email = "Email",
Date = DateTime.Now,
ImageUrl = null
},
ObjectId = "SHA",
TaggedObject = new GitObject
{
ObjectId = "SHA",
ObjectType = GitObjectType.Commit
},
Url = string.Empty
};
var sourceRepo = await gitClient.GetRepositoryAsync("PROJECT", repoName);
// This call works
var tags = await gitClient.GetTagRefsAsync(sourceRepo.Id);
// The tag is printed to the console
Console.WriteLine(tags.First().Name);
// This throws "VS30063: You are not authorized to access https://dev.azure.com"
await gitClient.CreateAnnotatedTagAsync(tag, "PROJECT", sourceRepo.Id);
There is an issue with your PAT token. I just created a tag using your code and PAT with FULL Access:
Can you create a new token and try again?
I have a notification that shows a button to start a timer. This button works fine on API25, but with API26 and greater, the button does nothing.
I have already set up a notification channel. The notification itself shows up correctly, so I don't think it's a channel issue.
Here I add the play/pause intent
var playPauseIntent = new Intent("com.example.example.timer");
var timerNotificationIntentValue = this.GetTimerNotificationIntentValue(timerAction);
playPauseIntent.PutExtra("timerNotification", timerNotificationIntentValue);
const int playPauseIntentId = 0;
var playPausePendingIntent = PendingIntent.GetBroadcast(this.context, playPauseIntentId, playPauseIntent, PendingIntentFlags.UpdateCurrent);
contentView.SetOnClickPendingIntent(Resource.Id.btn_start_pause, playPausePendingIntent);
And this is how I create the notification
var channelId = "11e9a3a1-aebf-425d-a9e8-fcc2fb139664";
var channelName = "General";
NotificationChannel channel;
channel = notificationManager.GetNotificationChannel(channelName);
if (channel == null)
{
channel = new NotificationChannel(channelId, channelName, NotificationImportance.Max);
channel.LockscreenVisibility = NotificationVisibility.Public;
notificationManager.CreateNotificationChannel(channel);
}
channel?.Dispose();
Notification.DecoratedCustomViewStyle notificationStyle = new Notification.DecoratedCustomViewStyle();
notification = new Notification.Builder(this.context, "11e9a3a1-aebf-425d-a9e8-fcc2fb139664")
.SetSmallIcon(Resource.Drawable.ic_logo)
.SetStyle(notificationStyle)
.SetCustomContentView(contentView)
.Build();
Then I just notify
notification.Flags |= NotificationFlags.OngoingEvent;
notificationManager.Notify("1", notification);
When tapping on the button, nothing happens on API26.
Something I notice, is that on API25, when I tap the button, I get to the BroadcastReceiver, whereas on API26 I don't
Changed this
var playPauseIntent = new Intent("com.example.example.timer");
to
var playPauseIntent = new Intent(this.context, typeof(MyNotificationBroadcastReceiver));
and now it seems to be working OK.
I use PayPal-NET-SDK for interact with PayPal system (sanbox). I have next code:
static void Main(string[] args)
{
try
{
var config = ConfigManager.Instance.GetProperties();
var accessToken = new OAuthTokenCredential(config).GetAccessToken();
var apiContext = new APIContext(accessToken);
var payment = Payment.Create(apiContext, new Payment
{
intent = "order",
payer = new Payer
{
payment_method = "paypal"
},
transactions = new List<Transaction>
{
new Transaction
{
description = "Transaction description.",
invoice_number = "002",
amount = new Amount
{
currency = "USD",
total = "15.00",
},
payee = new Payee
{
email = "test1#gmail.com"
}
}
},
redirect_urls = new RedirectUrls
{
return_url = "site for redirect", // in my code there is normal url
cancel_url = "site for redirect""
}
});
var approval = payment.GetTokenFromApprovalUrl();
var url = payment.GetApprovalUrl();
payment.token = approval;
var response = payment.Execute(apiContext, new PaymentExecution {payer_id = "C598R54Q6P39G" });
}
catch (PaymentsException e)
{
Console.WriteLine(e.Response);
}
}
After executing this code i receive bad request error from PayPal ("Payer has not approved payment"). If go to link in url in debug, i get to PayPal confirm page, and after push continue button, payment executing withoue exceptions (but funds still same, money is not sending). How i can send money to other paypal wallet without redirect to PayPal aproving page?
Resolved by using payout (as i uderstand, payments use for client to merchant transfer).
static void Main(string[] args)
{
try
{
// Authenticate with PayPal
var config = ConfigManager.Instance.GetProperties();
var accessToken = new OAuthTokenCredential(config).GetAccessToken();
var apiContext = new APIContext(accessToken);
var payout = Payout.Create(apiContext, new Payout
{
sender_batch_header = new PayoutSenderBatchHeader
{
email_subject = "Hello payout",
sender_batch_id = "ilab_Payout002",
recipient_type = PayoutRecipientType.EMAIL
},
items = new List<PayoutItem>
{
new PayoutItem
{
amount = new Currency
{
currency = "USD",
value = "17.5"
},
note = "Exchange is done!",
receiver = "ilab-test1#gmail.com",
recipient_type = PayoutRecipientType.EMAIL,
sender_item_id = "121341"
}
},
});
}
catch (PaymentsException e)
{
Console.WriteLine(e.Response);
}
}
}
I have created an adaptive card with C# AdaptiveCard SDK. But, once I deployed to Facebook Messenger, it won't show the adaptive card.
The key part of code is like this: (including initialize IMessageActivity and set up its properties
var botActivity = (Microsoft.Bot.Connector.Activity)context.Activity;
IMessageActivity reply = botActivity.CreateReply();
reply.AttachmentLayout = AttachmentLayoutTypes.List;
reply.Attachments = new List<Attachment>();
AdaptiveCard adaptiveCard = new AdaptiveCard()
{
Body = new List<AdaptiveElement>
{
new AdaptiveColumnSet
{
Columns = new List<AdaptiveColumn>
{
new AdaptiveColumn
{
Items = new List<AdaptiveElement>
{
new AdaptiveTextBlock
{
Size = AdaptiveTextSize.Large,
Text = "*",
Color = AdaptiveTextColor.Warning
}
}
},
new AdaptiveColumn
{
Size = "1px",
Items = new List<AdaptiveElement>
{
new AdaptiveTextBlock
{
Text = "indicates mandatory fields",
Size = AdaptiveTextSize.Medium,
Wrap = true
}
}
}
}
},
new AdaptiveTextBlock()
{
Text = " ",
Spacing = AdaptiveSpacing.Medium,
}
},
Actions = new List<AdaptiveAction>()
{
new AdaptiveSubmitAction()
{
Title = "Confirm",
DataJson = "{\"Type\": \"RequestBody\"}"
}
}
};
RenderedAdaptiveCard renderedAdaptiveCard = renderer.RenderCard(adaptiveCard);
Attachment plAttachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = renderedAdaptiveCard.OriginatingCard
};
reply.Attachments.Add(plAttachment);
await context.PostAsync(reply);
I also add the adaptive card to IMessageActivity attachment, and use context.PostAsync to post the reply with attachment back to user.
Anyone has any idea why I can't see the adaptive card in Facebook Messenger?
I tried create Telegram bot client with Microsoft Bot Framework, when I create signincard with this framework, signincard created successfully and I can see buttons in Microsoft Bot Emulator but when I publish to server and test it with Telegram, signincard not showing in bot, please tell me how to fix it.
code :
Activity reply = null;
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl), "", "");
if (activity.Type == ActivityTypes.Message)
{
if (activity.Text == "/start")
{
reply = activity.CreateReply($"Welcome, please select an option");
reply.Recipient = activity.From;
reply.Type = ActivityTypes.Message;
reply.Attachments = new List<Attachment>();
List<CardAction> cardButtons = new List<CardAction>();
var helpAction = new CardAction()
{
Image = "",
Title = "Get Menu",
Type = "imBack",
Value = "help"
};
var contactAction = new CardAction()
{
Image = "",
Title = "Contact Us",
Type = "imBack",
Value = "contact"
};
cardButtons.Add(helpAction);
cardButtons.Add(contactAction);
var sc = new SigninCard()
{
Buttons = cardButtons,
Text = ""
};
Attachment attach = sc.ToAttachment();
reply.Attachments.Add(attach);
}
else
{
}
}
await connector.Conversations.ReplyToActivityAsync(reply);
sorry for bad english.
I think sign-in card type must be "signin", and the value should be url instead of string
working code:
replyActivity.Attachments = new List<Attachment>();
var cardButtons = new List<CardAction>();
var plButton = new CardAction
{
Value = auth.SessionUrl,
Type = "signin",
Title = "Connect"
};
cardButtons.Add(plButton);
var plCard = new SigninCard("You need to authorize to use Quick Book feature", cardButtons);
var plAttachment = plCard.ToAttachment();
replyActivity.Attachments.Add(plAttachment);
replyActivity.Text = "Should go to conversation, sign-in card";
screenshot: