I am currently working on a bot project where i am trying to utilize Microsoft adaptive cards to try send a PaymentRequest to the user. I created a dummy paymentrequest object and inserted it into a Hero card like the documentation says.
var methodList = new List<PaymentMethodData>();
var method = new PaymentMethodData()
{Data = new {supportedNetworks = new[] { "visa", "mastercard", "amex", "discover", "diners", "jcb", "unionpay"} }, SupportedMethods = new[] { "https://bobpay.xyz/pay" } };
methodList.Add(method);
var details = new PaymentDetails {};
var test = new PaymentRequest(null, methodList, details);
var heroCard = new HeroCard
{
Title = "Bob",
Subtitle = "The Builder",
Text = "Kunnen wij het maken!",
Images = new List<CardImage>
{
new CardImage
{
Url = "https://m.media-amazon.com/images/M/MV5BNjRlYjgwMWMtNDFmMy00OWQ0LWFhMTMtNWE3MTU4ZjQ3MjgyXkEyXkFqcGdeQXVyNzU1NzE3NTg#._V1_CR0,45,480,270_AL_UX477_CR0,0,477,268_AL_.jpg"
}
},
Buttons = new List<CardAction>
{
new CardAction
{
Title = "Buy",
Type = PaymentRequest.PaymentActionType,
Value = test,
}
}
};
replyMessage.Attachments.Add(heroCard.ToAttachment());
await context.PostAsync(replyMessage);
I took out a bunch of parameters from the PaymentRequest constructor because i was experimenting with trying to get some kind of feedback. With this i get back nothing but this url which crashed the browser when i try to run it.
"content": {
"buttons": [
{
"title": "Buy",
"type": "openUrl",
"value": "payment://{\"methodData\":[{\"supportedMethods\":[\"https://bobpay.xyz/pay\"],\"data\":{}}],\"details\":{}}"
}
],
I can't find any documentation on how to do this properly but it doesnt seem to say it is deprecated on the documention. I am using bot framework v3 if that helps. I feel like even without some parameters in the PaymentRequest it should still give me something when i click the button.
As stated in this documentation: bot-builder-dotnet-request-payment In order to use the Bot Builder Payments library, you must first:
Create and activate a Stripe account if you don't have one already.
Sign in to Seller Center with your Microsoft account.
Within Seller Center, connect your account with Stripe.
Within Seller Center, navigate to the Dashboard and copy the value of
MerchantID.
Update your bot's Web.config file to set MerchantId to the value that
you copied from the Seller Center Dashboard.
At this time, the Bot Framework SDK supports only Stripe payments directly. If you are using some other provider, you will need to add support for it manually.
Also note: as of 2.25.2019, Bot Builder V4 sdk does not have payments support built in. The Bot Builder V3 sdk does: https://github.com/Microsoft/BotBuilder-Samples/tree/v3-sdk-samples/CSharp/sample-payments (Also, the Bot Framework Emulator V4 does not yet support payments: https://github.com/Microsoft/BotFramework-Emulator/issues/1324 The V3 emulator can be downloaded from here: https://github.com/Microsoft/BotFramework-Emulator/releases/tag/v3.5.37 )
Related
I am developing a bot with microsoft BotFramework.When bot sends an adaptive card the notification text is "Sent a Card".
Is there a way to modify this text?
Yes, you can change the text on the notification using "Summary" property of an activity.
You can go ahead and try out this sample code:
var response = MessageFactory.Text(string.Empty);
AdaptiveCard ad = new AdaptiveCard();
ad.Body = new List<AdaptiveElement>() {
new AdaptiveTextBlock()
{
Text= "testing",
Id ="testing"
}
};
Attachment att = new Attachment()
{
Content=ad,
ContentType= AdaptiveCard.ContentType
};
response.Attachments.Add(att);
response.Summary = "showing custom greeeting from the Bot - rather than send a card";
context.SendActivityAsync(response, cancellationToken);
I am new to bot framework and c# - we implemented a bot using a QnA maker knowledge base. I am trying to use adaptive cards with Adaptive Submit Actions.
Everything works perfectly in the WebChat, however in Teams I cannot display more than 6 submit actions at the same time...
Please find a test code below:
var demoActionList = new List<AdaptiveAction>();
for (int i=0; i<20; i++)
{
demoActionList.Add(
new AdaptiveSubmitAction()
{
Type = "Action.Submit",
Title = "title + "+i,
Data = new QnABot.Dialog.MsTeamsDataResponseWrapper() { MsTeamsResponse = new QnABot.Dialog.MsTeamsResponse() { Value = "title + " + i } }
});
}
var plCard = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0));
plCard.Actions = demoActionList;
var attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = plCard
};
chatActivity.Attachments.Add(attachment);
If I run this code in the webchat I will see all the 20 submit actions in the adaptive cards, however in ms teams I see only 6
Please see the example with teams, and the example with the webchat
Any idea how to display all the submit actions in the card with ms teams?
Teams does support carousels, so you could have multiple card attachments in a single activity like this.
This is a known hard limit in Teams right now - see this answer from someone at Microsoft not long ago: Can I show more than one button/option in teams using cards? which includes some suggested workarounds.
update: I'm also wondering if list cards might be of interest - it would look a bit similar to the web chat example you showed above - basically a long list of options.
I am trying to create an Adaptive forms using c#. I have installed Microsoft.AdaptiveCards Nuget package with Version 0.5.1 and Bot Builder version is 3.14.1.1.
My card has rendered correctly in Skype channel. But on click of Submit button, Forms input data Json is not passing to the Bot framework Post Activity. Submit Type is "Action.Submit". But this is working in Web chat.
I am using the below code.
var Makedmessage = context.MakeMessage();
AdaptiveCards.AdaptiveCard card = new AdaptiveCards.AdaptiveCard();
Attachment attach = new Attachment();
attach.ContentType = AdaptiveCards.AdaptiveCard.ContentType;
card.Body = new List<CardElement>() { new TextBlock() { Text = "Present a form and submit it back to the originator" }, new TextInput() { Id = "firstName", Placeholder = "What is your first name?" }, new TextInput() { Id = "lastName", Placeholder = "What is your last name?" } };
card.Actions = new List<ActionBase>() { new SubmitAction() { Title = "Action.Submit" } };
attach.Content = card;
Makedmessage.AttachmentLayout = AttachmentLayoutTypes.Carousel;
Makedmessage.Attachments.Add(attach);
await context.PostAsync(Makedmessage, CancellationToken.None);
Also attached the Screenshot.
How can I resolve this?
Adaptive cards are still under development for Skype channel. You will have to look for other alternative feature like multi dialog or formflow by Bot Framework to get the details of the user.
I am creating a Cortana skill on the Cortana canvas, I have a button.
I wanted to know if it possible to have an 'imback' type of button to open a webpage.
Ye, for example
var message = context.MakeMessage() as IMessageActivity;
message.ChannelData = JObject.FromObject(new
{
action = new { type = "LaunchUri", uri = "skype:echo123?call" }
});
await context.PostAsync(message);
this code will start a call with echo123 user on skype
Reference: https://learn.microsoft.com/en-us/cortana/tutorials/bot-skills/bot-entity-channel-data
You can supply an openUrl to a card action, or even use ChannelData to send a LaunchUri command, deep linking to an application. (I haven't tried this, but I assume 'http://websitename.com' will launch in the Cortana host platform's default browser.)
activity.ChannelData = new {
action = new { type = "LaunchUri", uri = "http://websitename.com"}
};
So my main objective is to update network user's outlook calendar from sql server data using office365 api every few minutes. I am stuck at how to get access for other user's outlook calendar? Looked at below link but didnt asnwser much...do i need azure subscription in order to do this? If someone can point me to right direction, that would be great
https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
I am stuck at how to get access for other user's outlook calendar?
In this case, you can consider using the application permission.
In Azure AD:
register a Web Application in your Azure AD.
add “Read and write calendars in all mail boxes” permission
generate the application secret key
In your application, call Office 365 Graph API - create events by using application token.
http://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/user_post_events
var tmgr = new ApplicationTokenManagement();
var token = tmgr.AcquireToken(Settings.ResourceUrlOfGraph);
var api = new Graph.GraphCalendarAPI(token);
JObject body = new JObject
{
{"subject", "Create from Office 365 API"},
{"start", new JObject { { "DateTime", "2016-03-09T00:00:00"}, { "TimeZone", "China Standard Time" } } },
{"end", new JObject { { "DateTime", "2016-03-10T00:00:00"}, { "TimeZone", "China Standard Time" } } },
{"isAllDay", true }
};
var task = api.CreateEventAsync(body, "user#youcompany.com");
task.Wait();
You can find the complete sample here.