Load settings from Configurable tab in Microsoft Teams bot - microsoft-teams

I am trying to load contentUrl that has been set during Tab configuration using MicrosoftTeams.js. Once I set the URL like this
microsoftTeams.settings.setSettings({
entityId: ******,
contentUrl: url
});
microsoftTeams.settings.setValidityState(state);
the app nice sets the tab.
But I need to access this contentUrl from Bot (to do some advanced API calls..) but there seems to be no way how to do this. Event session object is not aware of this settings.
Thank you for any kind of help.
I have tried exploring session object. My
My project is based on this demo: https://github.com/OfficeDev/msteams-samples-hello-world-nodejs

Related

How to fetch email internet headers in an on-send add-in?

We have a client that requires that an action take place when sending emails with certain Microsoft Information Protection/Azure Information Protection (MSIP/AIP) labels. We have a desktop Outlook add-in that does this perfectly.
Now however the client is requesting this same add-in but using the new modern style Outlook add-ins. We have created an on-send add-in to accomplish this, but we cannot get access to any internet headers in an Office.ComposeMessage. In fact, we cannot get any headers to be returned.
Here is our code:
async function fetchInternetHeaders(mailItem: Office.MessageCompose,
tags: string[]): Promise<string[]> {
return new Promise(function(resolve, reject) {
try {
let myTags: string[] = [
"msip_labels", // This is the value we need
"x-ms-has-attach", // This is for testing
"PR_SUBJECT_W", // This is for testing
"http://schemas.microsoft.com/mapi/proptag/0x0037001F", // test
"http://schemas.microsoft.com/mapi/proptag/0x5D07001F", // test
"http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/msip_labels/0x0000001F", // Another way to get msip_labels
];
mailItem.internetHeaders.getAsync(myTags, function(asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
debug.Log("onSend.fetchInternetHeaders", "Selected headers: " + JSON.stringify(asyncResult.value));
} else {
debug.Log(
"onSend.fetchInternetHeaders",
"Error getting selected headers: " + JSON.stringify(asyncResult.error)
);
}
resolve(["FetchedInternetHeaders"]);
});
} catch (error) {
debug.Log("onSend.fetchInternetHeaders", "Error occurred", error);
reject(error);
}
});
Note: We ignored the parameter "tags" to make everything as simple as possible.
The call succeeds but the returned array is always empty, even for simple properties like the email Subject. What are we doing wrong?
Both COM add-ins and Web add-ins don't provide any internet headers until the message is sent out. You may expect the internet headers set when the message is put to the Sent Items folder, but before that they are not created and stamped by the service/transport provider.
Most probably you need to access user properties, see the UserProperties object in the Outlook object model. But the Office JavaScript API (OfficeJS) doesn't provide anything for that out of the box, you need to use EWS or Graph API to access such properties from web add-ins.
You can specify data specific to an item in the user's mailbox using the CustomProperties object. For example, your mail add-in could categorize certain messages and note the category using a custom property messageCategory. Or, if your mail add-in creates appointments from meeting suggestions in a message, you can use a custom property to track each of these appointments. This ensures that if the user opens the message again, your mail add-in doesn't offer to create the appointment a second time.
Be aware, changes to custom properties are stored on in-memory copies of the properties for the current Outlook session. To make sure these custom properties will be available in the next session, use CustomProperties.saveAsync.
These add-in-specific, item-specific custom properties can only be accessed by using the CustomProperties object. Like I wrote earlier, these properties are different from the custom, MAPI-based UserProperties in the Outlook object model, and extended properties in Exchange Web Services (EWS). You cannot directly access CustomProperties by using the Outlook object model, EWS, or REST. To learn how to access CustomProperties using EWS or REST, see the section Get custom properties using EWS or REST.
You can post or vote for an existing feature request on Tech Community where they are considered when the Office dev team go through the planning process. Use the github label: Type: product feature request at https://aka.ms/M365dev-suggestions .

Sending notification to custom teams application

I am working on a custom app that will load data in the personal tab from an external system. Everything works fine when I am on the app.
If the user is on the Calls or Chat tab and the external system is having something new for the user we want to notify the user in the chat or activity feed so that the user can revisit the custom app and review the data.
Please suggest how to achieve it.
Thanks,
Pratap

MS Teams Messaging Extension submitTask failing with "v3 agent not found" error

I'm creating my first Microsoft Teams extension. For now I'm just trying to get the basic plumbing for a messaging extension working. I'm trying to build an extension which will allow a user to search for content in my service and then return a card into their compose window in personal and Teams chats.
I've tried to follow the basic guide ( https://learn.microsoft.com/en-us/microsoftteams/platform/messaging-extensions/how-to/create-messaging-extension ) for creating a messaging extension using App Studio. I've setup a bot as it describes, and I have built a dummy echobot endpoint for the bot (using Ruby). I am able to "chat" with my bot directly in the Teams client and it is able to respond.
My messaging extension defines an action based command with a taskInfo with a web view URL to render and a fetchTask set to false. I've written a basic static HTML page for this and included the teams-js library. The web view loads and the teams-js library initialization callback is called. I have a submit button which calls microsoftTeams.tasks.submitTask which as I understand it, should be calling my bot with a "composeExtension/submitAction" message to which I would respond with the card. (Based on https://learn.microsoft.com/en-us/microsoftteams/platform/messaging-extensions/how-to/action-commands/respond-to-task-module-submit?tabs=json )
I've tried installing my extension in Teams through the "Upload a custom app" option both as a "for me and my teams" and "for " but still have the following issues.
When I open my extension in the Teams client from the compose area and click this submit button in my iframe content, the submit I get a "Unable to reach app. Please try again" error displayed. In the dev console, I can see that the response to the "invoke" http post is {"errorCode":404,"message":"V3 agent not found."}
No traffic is actually sent to my bot during any of this process.
I saw this older post - Compose extension is throwing error : V3 agent not found . The https://dev.botframework.com/bots/ it refers to seems to be outdated, but in the Azure "Bot Channels Registration" console, I have gone to Channels and added "Microsoft Teams" (which I believe is the new equivalent).
Has anyone seen this happen and figured out what was going on? Much thanks!
Here is sample code for composeExtension/submitAction for Bot SDK V3. Make sure you pass the bot id and command text in taskInfo object.
case "composeExtension/submitAction":
string commandid = JsonConvert.DeserializeObject<Models.TaskModuleSubmitData<string>>(activityValue).commandId;
taskInfo = GetTaskInfo(commandid);
taskEnvelope = new Models.TaskEnvelope
{
Task = new Models.Task()
{
Type = Models.TaskType.Continue,
TaskInfo = taskInfo
}
};
return Request.CreateResponse(HttpStatusCode.OK, taskEnvelope);
Hilton had the right answer.
I had grabbed the Subscription ID from the Bot Channels Registration page instead of the App ID from the Azure Active Directory -> Apps Registration page and used that in the messaging extension manifest as the "botId" in the composeExtensions array. After fixing that I'm now getting messages submitted to my bot backend.

Chat history Persistence in MicroSoft Botframework WebChat window

I have a requirement of maintaining chat history and loading them back in a window after a page refresh or close and opening of the window.
ISSUE : Buttons/carousel/Adaptive cards/Hero Cards events/ properties are not loading (ie; when I click on button or any event, actions are not happening).
DESCRIPTION:
In order to achieve the requirement i had 2 options.
BotFramework _ Directline JS
I guess using this we can only get conversation history and where we couldn't load back the conversation history in chat window.
Though we can get the conversation history we have to send all the messages to bot again.
So i had opted 2nd one.
Store the html controls and Load it in the bot div: When sending or receiving message action is happening from bot am storing the html controls(i.e; controls under wc-message-groups class in local storage) and binding back to the div on page load if data exists.
This works for me to show conversation history in a chat window. But I am not able to get the events/actions for buttons.
Can we do this with Directline JS or is there any option to load properties/events to controls?
Please help me with this issue.
Thanks in Advance
I would start by taking a look at this thread out the Webchat GitHub repo. There is a good discussion going on about how this may be accomplished.
I also created this project in C# using webchat which will provide chat history in the webchat control. The project uses this pull request branch which you would also need to use. Hope this helps, good luck.

Creating a chat connector for communicating with the Bot Framework Service

I am trying to implement a bot in my website using the botbuilder framework for node.js. The function builder.ChatConnector() get the parameters appId and appPassword, does any one knows where can i found these appId and appPassword? It isn't clear for me in the microsoft documentation. The function is shown above:
function builder.ChatConnect
BotFramework documentation
You can find this information when you create your bot in Azure Bot Service, or when you proceed to register your bot at the dev portal.
Here's a brief walkthrough for registering through the dev portal with the minimum requirements. You'll need to fill out the name, bot handle and description for the bot as indicated below:
After this, you can scroll down and click on the button that says "Create Microsoft App ID and password".
Once you click on the button you'll be taken to a page with your bot name, your newly-generated App ID, and another button that allows you "Generate a password to continue".
After you click the button a small window will pop up with your password which you need to keep track of as it is only shown once!
NOTE: For developing and testing using the Emulator, you don't need this information just yet. You only need the AppID and password when you are making your bot public facing/deploying it.
You need to register your bot in https://dev.botframework.com/ and there you will get those values. Check this article that explains how to do that.

Resources