Sending locally stored image in hero card in Microsoft BotFramework The 2019 Stack Overflow Developer Survey Results Are In Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceHow to decide when to use Node.js?How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)How to download a file with Node.js (without using third-party libraries)?How to uninstall npm modules in node js?Using Node.js require vs. ES6 import/exportHow to resolve the issue of Displaying Hero Cards and Form Flow in Skype Channel?Microsoft Botframework encode image bytes into message cardsUsing locally stored images in hero cardMS Bot Framework: Begin Dialog When User Taps on Hero CardAdd a 'Show More' card in a carousel with botframework
Nested ellipses in tikzpicture: Chomsky hierarchy
Do warforged have souls?
What does Linus Torvalds mean when he says that Git "never ever" tracks a file?
What does "spokes" mean in this context?
Is 'stolen' appropriate word?
Could an empire control the whole planet with today's comunication methods?
Drawing vertical/oblique lines in Metrical tree (tikz-qtree, tipa)
How to make Illustrator type tool selection automatically adapt with text length
Make it rain characters
Why did Peik Lin say, "I'm not an animal"?
What's the point in a preamp?
Working through the single responsibility principle (SRP) in Python when calls are expensive
What force causes entropy to increase?
Homework question about an engine pulling a train
Store Dynamic-accessible hidden metadata in a cell
Can the DM override racial traits?
60's-70's movie: home appliances revolting against the owners
Is every episode of "Where are my Pants?" identical?
What to do when moving next to a bird sanctuary with a loosely-domesticated cat?
Using dividends to reduce short term capital gains?
Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?
Am I ethically obligated to go into work on an off day if the reason is sudden?
Single author papers against my advisor's will?
The following signatures were invalid: EXPKEYSIG 1397BC53640DB551
Sending locally stored image in hero card in Microsoft BotFramework
The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceHow to decide when to use Node.js?How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)How to download a file with Node.js (without using third-party libraries)?How to uninstall npm modules in node js?Using Node.js require vs. ES6 import/exportHow to resolve the issue of Displaying Hero Cards and Form Flow in Skype Channel?Microsoft Botframework encode image bytes into message cardsUsing locally stored images in hero cardMS Bot Framework: Begin Dialog When User Taps on Hero CardAdd a 'Show More' card in a carousel with botframework
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a image in my project directory. I need to display that image in hero card. Is it only possible to add images to hero cards from a URL?
If not how to add locally stored image in hero card or it is possible to choose any other card like adaptive which can use ?
node.js
add a comment |
I have a image in my project directory. I need to display that image in hero card. Is it only possible to add images to hero cards from a URL?
If not how to add locally stored image in hero card or it is possible to choose any other card like adaptive which can use ?
node.js
add a comment |
I have a image in my project directory. I need to display that image in hero card. Is it only possible to add images to hero cards from a URL?
If not how to add locally stored image in hero card or it is possible to choose any other card like adaptive which can use ?
node.js
I have a image in my project directory. I need to display that image in hero card. Is it only possible to add images to hero cards from a URL?
If not how to add locally stored image in hero card or it is possible to choose any other card like adaptive which can use ?
node.js
node.js
asked Mar 8 at 12:00
PrakashPrakash
72
72
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can encode the image into base64 and add it to your hero card. Use the fs package to create a bitmap of your image, create a new Buffer object with the bitmap, and convert the buffer to a base64 string. See the code snippets below for more details. Note, the file path must be the absolute path to the image.
Encode Image
const fs = require('fs');
function encodeBase64(path)
const bitmap = fs.readFileSync(path);
return new Buffer(bitmap).toString('base64')
Create HeroCard
createHeroCard(image, imageType='jpg')
return CardFactory.heroCard(
'BotFramework Hero Card',
CardFactory.images([`data:image/$imageType;base64,$encodeBase64(image)`, 'http://localhost:3978/dog.jpg']),
CardFactory.actions([
type: 'postBack',
title: 'Button',
value: 'Button'
])
);
Hope this helps!
Thanks for your response, it is working fine. But in the above method you should convert imageToBase64(path) to encodeBase64 because you define the function with one name and call them as another name.
– Prakash
Mar 9 at 5:26
Thank you for pointing that out - meant to change it. I've updated the code samples in my answer.
– tdurnford
Mar 9 at 20:51
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55062837%2fsending-locally-stored-image-in-hero-card-in-microsoft-botframework%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can encode the image into base64 and add it to your hero card. Use the fs package to create a bitmap of your image, create a new Buffer object with the bitmap, and convert the buffer to a base64 string. See the code snippets below for more details. Note, the file path must be the absolute path to the image.
Encode Image
const fs = require('fs');
function encodeBase64(path)
const bitmap = fs.readFileSync(path);
return new Buffer(bitmap).toString('base64')
Create HeroCard
createHeroCard(image, imageType='jpg')
return CardFactory.heroCard(
'BotFramework Hero Card',
CardFactory.images([`data:image/$imageType;base64,$encodeBase64(image)`, 'http://localhost:3978/dog.jpg']),
CardFactory.actions([
type: 'postBack',
title: 'Button',
value: 'Button'
])
);
Hope this helps!
Thanks for your response, it is working fine. But in the above method you should convert imageToBase64(path) to encodeBase64 because you define the function with one name and call them as another name.
– Prakash
Mar 9 at 5:26
Thank you for pointing that out - meant to change it. I've updated the code samples in my answer.
– tdurnford
Mar 9 at 20:51
add a comment |
You can encode the image into base64 and add it to your hero card. Use the fs package to create a bitmap of your image, create a new Buffer object with the bitmap, and convert the buffer to a base64 string. See the code snippets below for more details. Note, the file path must be the absolute path to the image.
Encode Image
const fs = require('fs');
function encodeBase64(path)
const bitmap = fs.readFileSync(path);
return new Buffer(bitmap).toString('base64')
Create HeroCard
createHeroCard(image, imageType='jpg')
return CardFactory.heroCard(
'BotFramework Hero Card',
CardFactory.images([`data:image/$imageType;base64,$encodeBase64(image)`, 'http://localhost:3978/dog.jpg']),
CardFactory.actions([
type: 'postBack',
title: 'Button',
value: 'Button'
])
);
Hope this helps!
Thanks for your response, it is working fine. But in the above method you should convert imageToBase64(path) to encodeBase64 because you define the function with one name and call them as another name.
– Prakash
Mar 9 at 5:26
Thank you for pointing that out - meant to change it. I've updated the code samples in my answer.
– tdurnford
Mar 9 at 20:51
add a comment |
You can encode the image into base64 and add it to your hero card. Use the fs package to create a bitmap of your image, create a new Buffer object with the bitmap, and convert the buffer to a base64 string. See the code snippets below for more details. Note, the file path must be the absolute path to the image.
Encode Image
const fs = require('fs');
function encodeBase64(path)
const bitmap = fs.readFileSync(path);
return new Buffer(bitmap).toString('base64')
Create HeroCard
createHeroCard(image, imageType='jpg')
return CardFactory.heroCard(
'BotFramework Hero Card',
CardFactory.images([`data:image/$imageType;base64,$encodeBase64(image)`, 'http://localhost:3978/dog.jpg']),
CardFactory.actions([
type: 'postBack',
title: 'Button',
value: 'Button'
])
);
Hope this helps!
You can encode the image into base64 and add it to your hero card. Use the fs package to create a bitmap of your image, create a new Buffer object with the bitmap, and convert the buffer to a base64 string. See the code snippets below for more details. Note, the file path must be the absolute path to the image.
Encode Image
const fs = require('fs');
function encodeBase64(path)
const bitmap = fs.readFileSync(path);
return new Buffer(bitmap).toString('base64')
Create HeroCard
createHeroCard(image, imageType='jpg')
return CardFactory.heroCard(
'BotFramework Hero Card',
CardFactory.images([`data:image/$imageType;base64,$encodeBase64(image)`, 'http://localhost:3978/dog.jpg']),
CardFactory.actions([
type: 'postBack',
title: 'Button',
value: 'Button'
])
);
Hope this helps!
edited Mar 9 at 20:51
answered Mar 8 at 17:20
tdurnfordtdurnford
957119
957119
Thanks for your response, it is working fine. But in the above method you should convert imageToBase64(path) to encodeBase64 because you define the function with one name and call them as another name.
– Prakash
Mar 9 at 5:26
Thank you for pointing that out - meant to change it. I've updated the code samples in my answer.
– tdurnford
Mar 9 at 20:51
add a comment |
Thanks for your response, it is working fine. But in the above method you should convert imageToBase64(path) to encodeBase64 because you define the function with one name and call them as another name.
– Prakash
Mar 9 at 5:26
Thank you for pointing that out - meant to change it. I've updated the code samples in my answer.
– tdurnford
Mar 9 at 20:51
Thanks for your response, it is working fine. But in the above method you should convert imageToBase64(path) to encodeBase64 because you define the function with one name and call them as another name.
– Prakash
Mar 9 at 5:26
Thanks for your response, it is working fine. But in the above method you should convert imageToBase64(path) to encodeBase64 because you define the function with one name and call them as another name.
– Prakash
Mar 9 at 5:26
Thank you for pointing that out - meant to change it. I've updated the code samples in my answer.
– tdurnford
Mar 9 at 20:51
Thank you for pointing that out - meant to change it. I've updated the code samples in my answer.
– tdurnford
Mar 9 at 20:51
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55062837%2fsending-locally-stored-image-in-hero-card-in-microsoft-botframework%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown