-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1e01a9
commit 8c07fdf
Showing
15 changed files
with
160 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,13 +29,13 @@ POST /api/v1/notify | |
|
||
### Parameters | ||
|
||
| Name | Required | Type | Description | | ||
| :---------- | :------- | :------------------------- | :----------------------------------------- | | ||
| **user** | Required | `string` | Name of the recipient for the notification | | ||
| **message** | Required | `string` or `Activity`(\*) | The notification | | ||
| mention | Optional | `boolean` | Append a mention to the user (@user) | | ||
| Name | Required | Type | Description | | ||
| :---------- | :------- | :---------------------------------------- | :-------------------------------------------------------------- | | ||
| **user** | Required | `string` | Name of the recipient for the notification | | ||
| **message** | Required | `string` or `Activity` or `RichCard` (\*) | The notification | | ||
| mention | Optional | `boolean` | Append a mention to the user (@user) (only for string messages) | | ||
|
||
> \*[Activity](https://www.npmjs.com/package/botframework-schema?activeTab=explore): JSON object defined in `botframework`. | ||
> \* `message` allows 3 formats, [read more](./message-format.md) | ||
### Response Codes | ||
|
||
|
@@ -58,16 +58,6 @@ curl -s -H "content-type: application/json"\ | |
} | ||
``` | ||
|
||
```bash | ||
# 202 | ||
curl -s -H "content-type: application/json"\ | ||
-d '{"user": "[email protected]", "message": {"text": "this is the text", "title": "this is the title"}}'\ | ||
localhost:3978/api/v1/notify | jq | ||
{ | ||
"conversationKey": "6afb0bc0-6ba7-11eb-98a1-211142846850|livechat" | ||
} | ||
``` | ||
|
||
```bash | ||
# 202 | ||
curl -s -H "content-type: application/json"\ | ||
|
@@ -110,18 +100,18 @@ POST /api/v1/broadcast | |
|
||
### Parameters | ||
|
||
| Name | Required | Type | Description | | ||
| :--------------------- | :------- | :------------------------- | :----------------------------------------------------------------------------------- | | ||
| **topic** | Required | `string` | Name of the topic: every user subscribed to this topic will receive the notification | | ||
| **message** | Required | `string` or `Activity`(\*) | The notification | | ||
| mention | Optional | `boolean` | Append a mention to the user (@user) | | ||
| createTopicIfNotExists | Optional | `boolean` | Ensure topic is created if wasn't registered on db | | ||
| Name | Required | Type | Description | | ||
| :--------------------- | :------- | :---------------------------------------- | :----------------------------------------------------------------------------------- | | ||
| **topic** | Required | `string` | Name of the topic: every user subscribed to this topic will receive the notification | | ||
| **message** | Required | `string` or `Activity` or `RichCard` (\*) | The notification | | ||
| mention | Optional | `boolean` | Append a mention to the user (@user) (only for string messages) | | ||
| createTopicIfNotExists | Optional | `boolean` | Ensure topic is created if wasn't registered on db | | ||
|
||
> \*[Activity](https://www.npmjs.com/package/botframework-schema?activeTab=explore): JSON object defined in `botframework`. | ||
> \* `message` allows 3 formats, [read more](./message-format.md) | ||
### Response Codes | ||
|
||
- **202 Accepted**: multiple notifications have been submitted to Microsoft's endpoint.<br> | ||
- **202 Accepted**: 1+ notifications have been submitted to Microsoft's endpoint.<br> | ||
Returns every used `conversationId` for traceability.<br> | ||
Note: empty list would mean that there are currently no subscribers to the given topic. | ||
- **400 Bad Request**: request body doesn't fulfill the requirements.<br> | ||
|
@@ -146,19 +136,7 @@ curl -s -H "content-type: application/json"\ | |
```bash | ||
# 202 | ||
curl -s -H "content-type: application/json"\ | ||
-d '{"topic": "banana", "message": {"text": "this is the text", "title": "this is the title"}}'\ | ||
localhost:3978/api/v1/broadcast | jq | ||
{ | ||
"conversationKeys": [ | ||
"6afb0bc0-6ba7-11eb-98a1-211142846850|livechat" | ||
] | ||
} | ||
``` | ||
|
||
```bash | ||
# 202 | ||
curl -s -H "content-type: application/json"\ | ||
-d '{"topic": "banana", "message": "hi there", "mention": true}'\ | ||
-d '{"topic": "banana", "message": "broadcasting to banana subscribers", "mention": true}'\ | ||
localhost:3978/api/v1/broadcast | jq | ||
{ | ||
"conversationKeys": [ | ||
|
@@ -360,3 +338,4 @@ curl -s -X PUT -H "content-type: application/json"\ | |
--- | ||
|
||
> - [Back to main README](../README.md) | ||
> - [More about `message` format](./message-format.md) |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# message format 🔡 | ||
|
||
Both `/api/v1/notify` & `/api/v1/broadcast` needs `message` as parameter. This message accepts 3 different formats: | ||
|
||
1. Plain `string`. | ||
|
||
2. [**`Activity`**](https://www.npmjs.com/package/botframework-schema?activeTab=explore): JSON object defined in `botframework-schema`. These JSON structures are what the framework accepts in the end. | ||
|
||
If the service detects the message is already formatted as an `Activity`, it will post it directly to `botframework`</br> | ||
Note: meant for debugging and repeatability | ||
|
||
Example of an `Activity` object. | ||
|
||
```json | ||
{ | ||
"type": "message", | ||
"inputHint": "acceptingInput", | ||
"attachmentLayout": "list", | ||
"attachments": [ | ||
{ | ||
"contentType": "application/vnd.microsoft.card.hero", | ||
"content": { | ||
"title": "Just 2 buttons", | ||
"buttons": [ | ||
{ | ||
"title": "Button no. 1", | ||
"value": "one", | ||
"type": "imBack" | ||
}, | ||
{ | ||
"title": "Button no. 2", | ||
"value": "two", | ||
"type": "imBack" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
3. [**`AdaptiveCard`**](https://docs.microsoft.com/en-us/adaptive-cards/): JSON object defined and supported by Microsoft. These JSON structures are what you'll typically use.</br> | ||
|
||
Adaptive Cards have wide support from Microsoft: | ||
|
||
- [docs](https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-reference#adaptive-card) | ||
- [schema reference](https://adaptivecards.io/explorer/) | ||
- [online designer](https://adaptivecards.io/designer/) | ||
|
||
Internally, if the service detects the message is an `AdaptiveCard` it will wrap it into an `Activity` before posting to `botframework`</br> | ||
Note: In the designer, make sure you set **target version to 1.2** | ||
|
||
Example of an `AdpativeCard` (v1.2) object. | ||
|
||
```json | ||
{ | ||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json", | ||
"type": "AdaptiveCard", | ||
"version": "1.2", | ||
"body": [ | ||
{ | ||
"type": "Container", | ||
"items": [ | ||
{ | ||
"type": "TextBlock", | ||
"text": "Megacoorp", | ||
"size": "Medium", | ||
"wrap": true | ||
}, | ||
{ | ||
"type": "TextBlock", | ||
"text": "The Future, Today", | ||
"isSubtle": true, | ||
"spacing": "None", | ||
"wrap": true | ||
}, | ||
{ | ||
"type": "TextBlock", | ||
"text": "{{DATE(2042-01-01T22:00:00+02:00, SHORT)}}", | ||
"wrap": true | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "Container", | ||
"spacing": "None", | ||
"items": [ | ||
{ | ||
"type": "ColumnSet", | ||
"columns": [ | ||
{ | ||
"type": "Column", | ||
"width": "stretch", | ||
"items": [ | ||
{ | ||
"type": "TextBlock", | ||
"text": "42", | ||
"size": "ExtraLarge", | ||
"wrap": true | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## API Call | ||
|
||
Remember that the `message` property should be defined in the first level. | ||
|
||
```bash | ||
curl -s -H "content-type: application/json"\ | ||
-d '{"user": "[email protected]", "message": { ... }}'\ | ||
localhost:3978/api/v1/notify | jq | ||
{ | ||
"conversationKey": "6afb0bc0-6ba7-11eb-98a1-211142846850|livechat" | ||
} | ||
``` | ||
|
||
```bash | ||
curl -s -H "content-type: application/json"\ | ||
-d '{"topic": "banana", "message": { ... }}'\ | ||
localhost:3978/api/v1/broadcast | jq | ||
{ | ||
"conversationKeys": [ | ||
"6afb0bc0-6ba7-11eb-98a1-211142846850|livechat" | ||
] | ||
} | ||
``` | ||
|
||
--- | ||
|
||
> - [To main README](../README.md) | ||
> - [Back to API docs](./api.md) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters