The Microsoft Health Bot provides API to enable programmatic management actions. For example, programmatic import and export of scenarios from the scenario editor.
-
Import/Export of scenarios
-
Create bot backup
-
Restore from backup
-
Import/Export of resource files
-
Import/Export of localization strings
-
Assign User access to management portal
The provided code samples demonstrate how to use the API.
The API is implemented with REST architecture, enabling to perform CRUD operations on resources that are represented as URLs.
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
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/.
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
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.
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
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
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
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]
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
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": []
}
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"
}