Skip to content

Latest commit

 

History

History
 
 

HealthAgentAPI

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Microsoft Health Bot Management API

Background

The Microsoft Health Bot provides API to enable programmatic management actions. For example, programmatic import and export of scenarios from the scenario editor.

The Management API supports the following actions:

  1. Import/Export of scenarios

  2. Create bot backup

  3. Restore from backup

  4. Import/Export of resource files

  5. Import/Export of localization strings

  6. Assign User access to management portal

How to use the API

Code samples

The provided code samples demonstrate how to use the API.

API Structure

The API is implemented with REST architecture, enabling to perform CRUD operations on resources that are represented as URLs.

API URL

The fully qualified domain name(FQDN) should match the FQDN of the portal used to log into the health bot admin panel for example:

URL: https://<region>.healthbot.microsoft.com/

List of regions:

eastus
westeurope
australiaeast
centralindia
eastus2
eastus2euap
northeurope
southcentralus
southeastasia
uksouth
westcentralus
westus2

API Security

The API is protected with standard JWT tokens. The JWT tokens contain two claims:

  • "tenantName": Taken from the management portal in the keys tab
  • "iat": timestamp as an UNIX epoch value

The JWT token is signed with an API secret, called API_JWT_secret. The secret is taken from the management portal, as shown in the following screenshot:

An exemplary JWT token payload before encoding is shown here:

{
  "tenantName": "myTenant",
  "iat": "1507056900"  
}

The JWT token is placed in the authorization header, according to the following example:

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnROYW1lIjoibXlUZW5hbnQiLCJpYXQiOiIxNTA3MDU2OTAwIn0.MN4DcxO2mLsltEYNpXbC6T6Bjxj3-rxIAObngZIw4-U

It is recommended to implement the JWT tokens with standard libraries, for example: Node.js "jsonwebtoken" library.More information at https://jwt.io/.

API Resources

Export Scenarios

URL: https://<region>.healthbot.microsoft.com/api/account/<yourTenantName>/scenarios

Method: GET

Special headers: Authorization: Bearer <JWT Token>

Request Parameters: None

Response: An array of JSON objects in the response body. Every object represents a Health Bot scenario

Examples:

GET https://eastus.healthbot.microsoft.com/api/account/healthagentprod/scenarios HTTP/1.1

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnROYW1lIjoiaGVhbHRoYWdlbnRwcm9kIiwiaWF0IjoxNTA2OTYwODAwfQ.x9oyA4kgfIgV5R1CpvMQeUYuP6FSlI65lx7Og8nMuWw

Host: healthbot.microsoft.com

HTTP/1.1 200 OK

[exported scenarios will appear in the response body]

Comments: N/A

Import Scenarios

URL: https://<region>.healthbot.microsoft.com/api/account/<yourTenantName>/scenarios

Method: POST

Special headers: Authorization: Bearer <JWT Token> , Content-type: application/json

Request Parameters: An array of JSON objects in request body. Every object represents a Health Bot scenario

Response: 200 OK in case of success

Examples:

POST https://eastus.healthbot.microsoft.com/api/account/healthagentprod/scenarios HTTP/1.1

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnROYW1lIjoiaGVhbHRoYWdlbnRwcm9kIiwiaWF0IjoxNTA2OTYxMzAwfQ.YGayhOc0fOaLRK4cWzRIhSsNH0zWOTy7Pe2PWSY5-cE

Host: healthbot.microsoft.com

Content-type: application/jsonContent-Length: 51116

[scenarios in request body]

Comments: When posting new scenarios, they will be added to the existing scenarios in the scenario editor. Scenario with the same name will be overridden.

Export bot backup

URL: https://<region>.healthbot.microsoft.com/api/account/<yourTenantName>/backup

Method: GET

Special headers: Authorization: Bearer <JWT Token>

Request Parameters: None

Response: A file in the response body. The file represents the bot backup.

Examples:

GET https://eastus.healthbot.microsoft.com/api/account/healthagentprod/backup HTTP/1.1

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnROYW1lIjoiaGVhbHRoYWdlbnRwcm9kIiwiaWF0IjoxNTA2OTYwODAwfQ.x9oyA4kgfIgV5R1CpvMQeUYuP6FSlI65lx7Og8nMuWw

Host: healthbot.microsoft.com

HTTP/1.1 200 OK

[exported bot backup will appear in the response body]

Comments: N/A

Restore from backup

URL: https://<region>.healthbot.microsoft.com/api/account/<yourTenantName>/backup

Method: POST

Special headers: Authorization: Bearer <JWT Token> , Content-type: application/json

Request Parameters: A file in the request body. The file represents the bot backup.

Response: 200 OK in case of success

Examples:

POST https://eastus.healthbot.microsoft.com/api/account/healthagentprod/backup HTTP/1.1

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnROYW1lIjoiaGVhbHRoYWdlbnRwcm9kIiwiaWF0IjoxNTA2OTYxMzAwfQ.YGayhOc0fOaLRK4cWzRIhSsNH0zWOTy7Pe2PWSY5-cE

Host: healthbot.microsoft.com

Content-type: application/jsonContent-Length: 51116

Export Resources

URL: https://<region>.healthbot.microsoft.com/api/account/<yourTenantName>/resources

Method: GET

Special headers: Authorization: Bearer <JWT Token>

Request Parameters: None

Response: An array of JSON objects in the response body. Every object represents a Resource

Examples:

GET https://eastus.healthbot.microsoft.com/api/account/healthagentprod/resources HTTP/1.1

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnROYW1lIjoiaGVhbHRoYWdlbnRwcm9kIiwiaWF0IjoxNTA2OTYwODAwfQ.x9oyA4kgfIgV5R1CpvMQeUYuP6FSlI65lx7Og8nMuWw

Host: healthbot.microsoft.com

HTTP/1.1 200 OK

[exported resources will appear in the response body]

Comments: N/A

Import Resources

URL: https://<region>.healthbot.microsoft.com/api/account/<yourTenantName>/resources

Method: POST

Special headers: Authorization: Bearer <JWT Token> , Content-type: application/json

Request Parameters: Resourse Files in request body. Every File represents a Resourse of Health Bot scenario **The file name cannot contain spaces or special characters

Response: 200 OK in case of success

Examples:

POST https://eastus.healthbot.microsoft.com/api/account/healthagentprod/resources HTTP/1.1

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnROYW1lIjoiaGVhbHRoYWdlbnRwcm9kIiwiaWF0IjoxNTA2OTYxMzAwfQ.YGayhOc0fOaLRK4cWzRIhSsNH0zWOTy7Pe2PWSY5-cE

Host: healthbot.microsoft.com

[Resources in request body]

Export Localization

URL: https://<region>.healthbot.microsoft.com/api/account/<yourTenantName>/localization

Method: GET

Special headers: Authorization: Bearer <JWT Token>

Request Parameters: None

Response: An array of JSON objects in the response body. Every object represents a localization string

Examples:

GET https://eastus.healthbot.microsoft.com/api/account/healthagentprod/localization

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnROYW1lIjoiaGVhbHRoYWdlbnRwcm9kIiwiaWF0IjoxNTA2OTYwODAwfQ.x9oyA4kgfIgV5R1CpvMQeUYuP6FSlI65lx7Og8nMuWw

Host: healthbot.microsoft.com

HTTP/1.1 200 OK

Comments: N/A

Import Localization

URL: https://<region>.healthbot.microsoft.com/api/account/<yourTenantName>/localization

Method: POST

Special headers: Authorization: Bearer <JWT Token> , Content-type: application/json

Request Parameters: An array of JSON objects in request body. Every object represents a Localization string of Health Bot scenario

Body Format:

{
    "custom": [{
        "<language>": "test",
        "stringId": "test"

    }],
    "system": []
}

List of language:

 en-us,
 ar-sa,
 cs-cz,
 de-de,
 el-gr,
 en-gb,
 es-es,
 es-mx,
 et-ee,
 fr-ca,
 fr-fr,
 it-it,
 nl-nl,
 pl-pl,
 pt-br,
 pt-pt,
 ro-ro,
 ru-ru,
 sk-sk,
 tr-tr,
 uk-ua,
 zh-cn

Response: 200 OK in case of success

Examples:

POST https://eastus.healthbot.microsoft.com/api/account/healthagentprod/localization HTTP/1.1

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnROYW1lIjoiaGVhbHRoYWdlbnRwcm9kIiwiaWF0IjoxNTA2OTYxMzAwfQ.YGayhOc0fOaLRK4cWzRIhSsNH0zWOTy7Pe2PWSY5-cE

Host: healthbot.microsoft.com

Content-type: application/jsonContent-Length: 51116

Request body:

{
    "custom": [{
        "en-us": "test1",
        "stringId": "test1"

    }],
    "system": []
}

Assign User access to management portal

URL: https://<region>.healthbot.microsoft.com/api/account/<yourTenantName>/user

Method: POST

Special headers: Authorization: Bearer <JWT Token> , Content-type: application/json

Request Parameters: email and role ("Reader", "Editor", "Admin)

Body Format:

{
    "email": "[email protected]",
    "role": "Editor"
}

Response: 200 OK in case of success

Examples:

POST https://eastus.healthbot.microsoft.com/api/account/healthagentprod/user HTTP/1.1

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnROYW1lIjoiaGVhbHRoYWdlbnRwcm9kIiwiaWF0IjoxNTA2OTYxMzAwfQ.YGayhOc0fOaLRK4cWzRIhSsNH0zWOTy7Pe2PWSY5-cE

Host: healthbot.microsoft.com

Request body:

{
    "email": "[email protected]",
    "role": "Editor"
}