PowerBI Tile on WebChat
Hi,
Can we embed PowerBI Tile as bot's response? If Yes, how can we do that. I have looked into PowerBI Embed integration to web applications. Can we use anything similar to embed PowerBI tile into webchat?
Thanks, Naveen
@naveenwinsome, to be clear, are you wanting the embedded tile to display as part of the web chat conversation (i.e. within web chat)? Or, are you wanting the embedded tile to display on the page as a result of the user requesting it from the bot?
@stevkan I'm looking for embed tile to be displayed as a part of webchat conversation.
For example, if user asks "display sales data of 2019". Bot should respond with embed tile of Power BI.
Thanks, Naveen
@stevkan Can you take a look at the comments when you get a chance
@naveenwinsome, this is possible using activityMiddleware to update the HTML associated to an activity.
In this example, I am sending an adaptive card from the bot that carries a flag. When the flag is caught by Web Chat, the Power BI embed code is appended which then displays for the user to interact with.
First step: I send a basic adaptive card that contains a button ("Request Assistance") and a generic trigger property to act as a flag.
async basicAdaptiveCard ( stepContext ) {
const card = {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Hi!! How can I help you today?",
"weight": "Bolder",
"size": "Medium"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Request Assistance",
"data": "close"
}
],
"trigger": "cardTrigger"
}
const ac_card = CardFactory.adaptiveCard( card );
await stepContext.context.sendActivity(
{
attachments: [ ac_card ]
}
);
return { status: DialogTurnStatus.waiting };
}
Second step: In Web Chat, I use activityMiddleware to check for the trigger flag in order to filter the incoming messages. Once I've identified the correct card has been received, I then cycle thru all the HTML elements with the ac-adaptiveCard class. The last element in the loop should be the card housing the respective activity. I then locate the lastChild element in the card element which, for simplicity, I have made the "Request Assistance" button. I then "append" the iFrame to the innerHTML which adds it to the bottom of the adaptive card element.
Note: I assign the id "cardPowerBI" to the card element to be used in the next step. I have also set the iFrame width and height to fit into the card's bubble. When the bubble is set to a maxWidth of 650px, then the iFrame width of 615px fits inside nicely matching the width of the image of the preceeding "welcome" card. You will want to play with the CSS. Lastly, note I added a setTimeout. Because this is middleware, if you don't add a slight delay then the middleware finishes processing before the incoming activities are processed and rendered by Web Chat.
const activityMiddleware = () => next => card => {
const { activity: { id, from, name, text, type, attachments, channelData } } = card;
if (type === 'message' && from.role === 'bot') {
if(attachments && attachments[0].content.trigger === 'cardTrigger') {
setTimeout(() => {
let children = document.getElementsByClassName('ac-adaptiveCard');
for (let i = 0, j = children.length; i <= j; i++) {
if(i === j - 1) {
let child = children[i];
child.id = 'cardPowerBI';
if(child.lastChild.innerHTML.includes('Request Assistance')) {
child.lastChild.innerHTML += '<iframe width="615" height="730" src="https://app.powerbi.com/reportEmbed?..." frameborder="0" allowFullScreen="true"></iframe>'
}
}
}
}, 300)
}
}
return next(card);
}
Last step: I add CSS and styleOptions. The CSS put a little space between the button and the appended iFrame. The styleOptions sets the bubble width.
#cardPowerBI .ac-actionSet {
padding-bottom: 5px;
};
iframe {
width: 615px;
height: 730px;
}
const styleOptions = {
bubbleMaxWidth: 650,
};
Hope of help!

Closing this issue as resolved.
@stevkan - Thanks for the solution. Let me try out and get back to you if I need anything else.
Thanks, Naveen
@stevkan -how to integrate the same thing with MS Teams.
its not working for me , facing html issue. so iframe links contains sales data in image format right ?