Jason Shave
Jason Shave

Reputation: 2672

How to get webHookUrl from Microsoft Teams connector

I’m building a connector for Teams and I can get my custom configuration page to load by calling the necessary functions. I have a few <span> tags in my page just to debug and I'm populating the tags with properties from my call to "getSettings()".

<script>
    microsoftTeams.initialize();

    var teamsSettings = microsoftTeams.settings.getSettings(); //should this not return at least something?
    if (teamsSettings == null) {
        $(document).ready(function () {
            document.getElementById('status').textContent = "Get settings 
returned null!"; //i always get null
        });
    } else {
        document.getElementById('entityId').textContent = teamsSettings.entityId;
        document.getElementById('configName').textContent = teamsSettings.configName;
        document.getElementById('contentUrl').textContent = teamsSettings.contentUrl;
        document.getElementById('webhookUrl').textContent = teamsSettings.webhookUrl;
        document.getElementById('appType').textContent = teamsSettings.appType;
        document.getElementById('userObjectId').textContent = teamsSettings.userObjectId;
    }

    microsoftTeams.settings.registerOnSaveHandler(function (saveEvent) {
        saveEvent.notifySuccess();
    });

    function onClick() {
        microsoftTeams.settings.setValidityState(true);
    }
</script>

So I’m wondering if the getSettings() method is even running as my label element is blank. How can I troubleshoot the JavaScript interactions while configuring my connector in Teams? Is there a better way to view settings obtained from the method?

Upvotes: 0

Views: 400

Answers (1)

Gousia Begum
Gousia Begum

Reputation: 2124

Here is the code snippet to get the webhookUrl using getSettings().

microsoftTeams.initialize();
microsoftTeams.settings.getSettings(function (settings) {

   document.getElementById('webhookUrl').textContent = settings.webhookUrl;

});

Upvotes: 3

Related Questions