本文整理汇总了TypeScript中botbuilder.CardAction.openUrl方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CardAction.openUrl方法的具体用法?TypeScript CardAction.openUrl怎么用?TypeScript CardAction.openUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类botbuilder.CardAction
的用法示例。
在下文中一共展示了CardAction.openUrl方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: step1
private static async step1(session: builder.Session, args?: any | builder.IDialogResult<any>, next?: (args?: builder.IDialogResult<any>) => void): Promise<void> {
let buttons = new Array<builder.CardAction>();
if (isMessageFromChannel(session.message)) {
// create button to deep link to the configurable channel tab - configurable channel tab must have been added for this to work
// pattern for configurable channel tab deep link:
// https://teams.microsoft.com/l/entity/APP_ID/ENTITY_ID?webUrl=ENTITY_WEB_URL&label=<entityLabel>&context=CONTEXT
// APP_ID is the appId assigned in the manifest
// ENTITY_ID is the entityId that is set for that channel tab when your config page creates it
// ENTITY_WEB_URL is a url that is opened in a browswer on a mobile device if this url is opened on a mobile device
// CONTEXT is a url encoded json object with a channelId parameter inside of it
let appId = config.get("app.appId");
let configTabEntityId = "test123";
let queryParams = querystring.stringify({ context: "{\"channelId\":\"" + session.message.sourceEvent.channel.id + "\"}" });
let configTabHardCodedUrl = "https://teams.microsoft.com/l/entity/" + appId + "/" + configTabEntityId + "?" + queryParams;
buttons.push(builder.CardAction.openUrl(session, configTabHardCodedUrl, Strings.open_configurable_tab));
}
// create a button to deep link to the static tab located in the 1:1 chat with the bot
// pattern for static tab deep link:
// (at a minimum to get to the static tab)
// https://teams.microsoft.com/l/entity/28:BOT_ID/ENTITY_ID?conversationType=chat
// (for sending data to that tab) - look at the HelpDialog for an example
// https://teams.microsoft.com/l/entity/28:BOT_ID/ENTITY_ID?conversationType=chat&context=CONTEXT
// BOT_ID is the bot id that comes from your bot registration with 28: added to the front
// ENTITY_ID is the entityId that is set for that static tab in the manifest
// CONTEXT is a url encoded json object with a subEntityId parameter inside of it – this is how you can pass data to your static tab
// e.g. %7B%22subEntityId%22%3A%22SUB_ENTITY_ID_DATA%22%7D
let botId = "28:" + config.get("bot.botId");
let staticTabEntityId = "1on1test123"; // this comes from the manifest file
let queryParams = querystring.stringify(
{
conversationType: "chat",
context: JSON.stringify({ subEntityId: "stuff" }),
},
);
let staticTabHardCodedUrl = "https://teams.microsoft.com/l/entity/" + botId + "/" + staticTabEntityId + "?" + queryParams;
buttons.push(builder.CardAction.openUrl(session, staticTabHardCodedUrl, Strings.open_static_tab));
let newCard = new builder.HeroCard(session)
.text(Strings.deeplink_card_text, staticTabHardCodedUrl)
.buttons(buttons);
session.send(new builder.Message(session)
.addAttachment(newCard));
session.endDialog();
}
示例2: step1
private static async step1(session: builder.Session, args?: any | builder.IDialogResult<any>, next?: (args?: builder.IDialogResult<any>) => void): Promise<void> {
let buttons = new Array<builder.CardAction>();
let botId = "28:" + config.get("bot.botId");
let staticTabEntityId = "1on1test123"; // this comes from the manifest file
let queryParams = querystring.stringify(
{
conversationType: "chat",
// context: "{\"subEntityId\":\"allCommands\"}",
context: JSON.stringify({ subEntityId: "allCommands" }),
},
);
// hardCodedUrl has url encoded {"subEntityId":"allCommands"} set as the context
let staticTabHardCodedUrl = "https://teams.microsoft.com/l/entity/" + botId + "/" + staticTabEntityId + "?" + queryParams;
buttons.push(builder.CardAction.openUrl(session, staticTabHardCodedUrl, Strings.all_commands_button));
let newCard = new builder.HeroCard(session)
.text(Strings.help_msg)
.buttons(buttons);
session.send(new builder.Message(session)
.addAttachment(newCard));
session.endDialog();
}
示例3: showUserProfile
// Show user profile
protected async showUserProfile(session: builder.Session): Promise<void> {
let linkedInApi = this.authProvider as GoogleProvider;
let userToken = this.getUserToken(session);
if (userToken) {
let profile = await linkedInApi.getProfileAsync(userToken.accessToken, [ "names", "emailAddresses", "photos", "urls" ]);
let name = this.findPrimaryValue(profile.names);
let email = this.findPrimaryValue(profile.emailAddresses);
let photo = this.findPrimaryValue(profile.photos);
let profileUrl = this.findPrimaryValue(profile.urls);
let profileCard = new builder.ThumbnailCard()
.title(name.displayName)
.subtitle(email.value)
.buttons([
builder.CardAction.openUrl(session, profileUrl.value, "View on Google"),
])
.images([
new builder.CardImage()
.url(photo.url)
.alt(name.displayName),
]);
session.send(new builder.Message().addAttachment(profileCard));
} else {
session.send("Please sign in to Google so I can access your profile.");
}
await this.promptForAction(session);
}
示例4: showUserProfile
// Show user profile
protected async showUserProfile(session: builder.Session): Promise<void> {
let linkedInApi = this.authProvider as LinkedInProvider;
let userToken = this.getUserToken(session);
if (userToken) {
let profile = await linkedInApi.getProfileAsync(userToken.accessToken, [ "formatted-name", "headline", "picture-url", "public-profile-url", "location", "num-connections", "num-connections-capped" ]);
let profileCard = new builder.ThumbnailCard()
.title(profile.formattedName)
.subtitle(profile.headline)
.text(`${profile.location.name} • ${profile.numConnections}${profile.numConnectionsCapped ? "+" : ""} connections`)
.buttons([
builder.CardAction.openUrl(session, profile.publicProfileUrl, "View on LinkedIn"),
])
.images([
new builder.CardImage()
.url(profile.pictureUrl)
.alt(profile.formattedName),
]);
session.send(new builder.Message().addAttachment(profileCard));
} else {
session.send("Please sign in to LinkedIn so I can access your profile.");
}
await this.promptForAction(session);
}
示例5: getConfigResponse
// create a response to prompt for a configuration
function getConfigResponse(): teams.IComposeExtensionResponse {
// the width and height parameters are optional, but will be used to try and create a popup of that size
// if that size popup cannot be created, as in this example, then Teams will create the largest allowed popup
let hardCodedUrl = config.get("app.baseUri") + "/composeExtensionSettings?width=5000&height=5000";
let response = teams.ComposeExtensionResponse.config().actions([
builder.CardAction.openUrl(null, hardCodedUrl, "Config"),
]).toResponse();
return response;
}
示例6: formatCarouselMessage
/**
* Format points of interest to a carousel message
* @method formatCarouselMessage
* @param {builder.Session} session
* @param {IStoredData} place
* @param {SpatialData} data
*/
function formatCarouselMessage(session: builder.Session, place: IStoredData, data: SpatialData): builder.Message {
let cards = new Array<builder.HeroCard>();
let isLatitudeLongitude: boolean;
if (place.location.geo && place.location.geo.latitude && place.location.geo.longitude) {
isLatitudeLongitude = true;
}
else {
isLatitudeLongitude = false;
}
let bingUrl = 'https://bing.com';
let notfound_text = session.localizer.gettext(session.preferredLocale(), "notfound_message", "places")
let message = new builder.Message(session)
.text(notfound_text);
// Ensure we returns only a maximum of five answers.
if (data && data.d && data.d.results && data.d.results.length > 0) {
for (let item of data.d.results) {
if (isLatitudeLongitude) {
// Bing maps Uri scheme (https://msdn.microsoft.com/en-us/library/dn217138.aspx)
bingUrl = `https://bing.com/maps/default.aspx?rtp=pos.${place.location.geo.latitude}_${place.location.geo.longitude}~pos.${item.Latitude}_${item.Longitude}_${item.DisplayName}&rtop=0~1~0`;
}
else {
bingUrl = `https://bing.com/maps/default.aspx?rtp=adr.${place.location}~pos.${item.Latitude}_${item.Longitude}_${item.DisplayName}&rtop=0~1~0`;
}
cards.push(new builder.ThumbnailCard(session)
.title(item.DisplayName)
.subtitle(`${item.AddressLine}, ${item.Locality}`)
.buttons([
builder.CardAction.openUrl(session, bingUrl, "get directions")
])
);
}
let foundplaces_text = session.localizer.gettext(session.preferredLocale(), "foundplaces_message", "places")
message = new builder.Message(session)
.text(foundplaces_text)
.attachmentLayout(builder.AttachmentLayout.carousel)
.attachments(cards);
}
return message;
}
示例7: request
(session: any, results: any) => {
session.send('Ok!');
session.send('Here is the nearest store I have found. A seller will be able to answer your questions. :)');
var address = "3 bis, rue rottembourg 75012 PARIS" //results.response;
var res = request('GET', 'http://dev.virtualearth.net/REST/v1/Locations?countryRegion=FR&key=AsiCMSmOq6O3MzsI4F7HqUXmB2JY7E76gdaCgtlranURBYOHgbariAXQxJURoTE8&addressLine=' + address);
var bing = JSON.parse(res.getBody('utf8'));
if (bing.resourceSets[0].estimatedTotal) {
let lat = bing.resourceSets[0].resources[0].point.coordinates[0];
let lng = bing.resourceSets[0].resources[0].point.coordinates[1];
this._store = [Number.MAX_SAFE_INTEGER, null];
for (let i = 0, len = this._stores.length; i < len; i++) {
let distance = this._geolocalisation.getDistanceFromLatLonInKm(lat, lng, this._stores[i].localisation.lat, this._stores[i].localisation.lng)
if (distance < this._store[0]) {
this._store[0] = distance;
this._store[1] = this._stores[i];
}
}
var msg = new builder.Message(session)
.textFormat(builder.TextFormat.xml)
.attachmentLayout(builder.AttachmentLayout.carousel)
.attachments([
new builder.HeroCard(session)
.title(this._store[1].name)
.text("12 Rue Halévy, 75009 Paris")
.images([
builder.CardImage.create(session, "http://www.timstanleyphoto.com/HDR/2012/i-GrS2b37/0/L/MicrosoftStore-L.jpg")
.tap(builder.CardAction.showImage(session, "http://www.timstanleyphoto.com/HDR/2012/i-GrS2b37/0/L/MicrosoftStore-L.jpg")),
])
.buttons([
builder.CardAction.openUrl(session, "http://bing.com/maps/default.aspx?rtp=adr." + "39%20quai%20du%20president%20roosevelt%2092130%20issy%20les%20moulineaux" + "~adr." + "12 Rue Halévy, 75009 Paris" + "&rtop=0~1~0", "Bing Direction"),
builder.CardAction.imBack(session, "Let's go !", "Go")
])
]);
builder.Prompts.choice(session, msg, "Let's go !");
} else {
session.send('I cannot find a store near you, try with a different address');
}
},
示例8: sendAuthorizeMsg
private static async sendAuthorizeMsg(session: builder.Session, args?: any | builder.IDialogResult<any>, next?: (args?: builder.IDialogResult<any>) => void): Promise<void> {
// let url = VSTSTokenOAuth2API.getUserAuthorizationURL();
// let newCard = new builder.SigninCard(session)
// .button(
// Strings.sign_in,
// url,
// )
// .text(Strings.default_text);
let buttons = [];
// buttons.push(builder.CardAction.openUrl(session, url, Strings.sign_in));
let botId = "28:" + config.get("bot.botId");
let staticTabEntityId = "1on1test123"; // this comes from the manifest file
let queryParams = querystring.stringify(
{
conversationType: "chat",
// context: "{\"subEntityId\":\"allCommands\"}",
context: JSON.stringify({ subEntityId: "vstsAuth" }),
},
);
let staticTabHardCodedUrl = "https://teams.microsoft.com/l/entity/" + botId + "/" + staticTabEntityId + "?" + queryParams;
buttons.push(builder.CardAction.openUrl(session, staticTabHardCodedUrl, Strings.sign_in));
let newCard = new builder.ThumbnailCard(session)
.title(Strings.default_title)
.subtitle(Strings.default_subtitle)
.text(Strings.default_text)
.images([
new builder.CardImage(session)
.url(config.get("app.baseUri") + "/assets/computer_person.jpg")
.alt(Strings.img_default),
])
.buttons(buttons);
// Just for development to see what the session.message.address values are
// session.send(encodeURIComponent(JSON.stringify(session.message.address)));
session.endDialog(new builder.Message(session).addAttachment(newCard));
}
示例9:
(session: any) => {
var msg = new builder.Message(session)
.textFormat(builder.TextFormat.xml)
.attachmentLayout(builder.AttachmentLayout.carousel)
.attachments([
new builder.HeroCard(session)
.title("Acer Swift 3")
.text("Ultra-Thin & Light")
.images([
builder.CardImage.create(session, "http://static.acer.com/up/Resource/Acer/Notebooks/Swift%203/Photogallery/20160823/Swift-3_Fingerprint_gold_gallery_04.png")
.tap(builder.CardAction.showImage(session, "http://www.acer.com/ac/en/US/content/series/swift3"))
])
.buttons([
builder.CardAction.openUrl(session, "https://www.bing.com/", "Buy online"),
builder.CardAction.imBack(session, "Acer Swift 3", "Real store")
]),
new builder.HeroCard(session)
.title("ASUS UX 360")
.text("360° of Freedom. 100% ZenBook.")
.images([
builder.CardImage.create(session, "http://www.ultrabookreview.com/wp-content/uploads/2016/06/asus-zenbook-ux360-3.jpg")
.tap(builder.CardAction.showImage(session, "https://www.asus.com/us/Notebooks/ASUS-ZenBook-Flip-UX360CA/"))
])
.buttons([
builder.CardAction.openUrl(session, "https://www.bing.com/", "Buy online"),
builder.CardAction.imBack(session, "ASUS UX 360", "Real store")
]),
new builder.HeroCard(session)
.title("LENOVO YOGA 900")
.text("The Yoga 900 is unbelievably thin and elegant.")
.images([
builder.CardImage.create(session, "http://winsupersite.com/site-files/winsupersite.com/files/gallery_images/02_Hero_Shot_VIDEO_Gold.jpg?1445276665")
.tap(builder.CardAction.showImage(session, "http://winsupersite.com/site-files/winsupersite.com/files/gallery_images/02_Hero_Shot_VIDEO_Gold.jpg?1445276665"))
])
.buttons([
builder.CardAction.openUrl(session, "https://www.bing.com/", "Buy online"),
builder.CardAction.imBack(session, "LENOVO YOGA 900", "Real store")
]),
new builder.HeroCard(session)
.title("SAMSUNG TAB PRO S")
.text("Work and Fun.")
.images([
builder.CardImage.create(session, "http://www.samsung.com/us/explore/tab-pro-s-features-and-specs/assets/images/configurator/desktop/tabpro-s_black.jpg")
.tap(builder.CardAction.showImage(session, "http://www.samsung.com/us/explore/tab-pro-s-features-and-specs/"))
])
.buttons([
builder.CardAction.openUrl(session, "https://www.bing.com/", "Buy online"),
builder.CardAction.imBack(session, "SAMSUNG TAB PRO S", "Real store")
]),
new builder.HeroCard(session)
.title("HP Spectre X360")
.text("360 degrees of versatility. Zero compromises.")
.images([
builder.CardImage.create(session, "http://images.techhive.com/images/article/2015/10/hp-spectre_x360_media-mode_right-facing-100620373-large.jpg")
.tap(builder.CardAction.showImage(session, "http://store.hp.com/us/en/mdp/Laptops/spectre-x360-211501--1"))
])
.buttons([
builder.CardAction.openUrl(session, "https://www.bing.com/", "Buy online"),
builder.CardAction.imBack(session, "HP Spectre X360", "Real store")
]),
new builder.HeroCard(session)
.title("I don't know !")
.text("Help me to choose.")
.images([
builder.CardImage.create(session, "http://www.silicon.fr/wp-content/uploads/2016/06/Windows-10-684x513.jpg")
.tap(builder.CardAction.showImage(session, "http://xpsbydell.com/?dgc=IR&cid=XPSfamily-263489&lid=2-1&ref=bnn"))
])
.buttons([
builder.CardAction.imBack(session, "I don't know", "I don't know")
])
]);
builder.Prompts.choice(session, msg, "Acer Swift 3|ASUS UX 360|SAMSUNG TAB PRO S|LENOVO YOGA 900|HP Spectre X360|I don't know");
},