activitysmith 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -36,11 +36,14 @@ const activitysmith = new ActivitySmith({
|
|
|
36
36
|
|
|
37
37
|
### Send a Push Notification
|
|
38
38
|
|
|
39
|
+
<p align="center">
|
|
40
|
+
<img src="https://cdn.activitysmith.com/features/new-subscription-push-notification.png" alt="Push notification example" width="680" />
|
|
41
|
+
</p>
|
|
42
|
+
|
|
39
43
|
```ts
|
|
40
44
|
const response = await activitysmith.notifications.send({
|
|
41
45
|
title: "New subscription 💸",
|
|
42
46
|
message: "Customer upgraded to Pro plan",
|
|
43
|
-
channels: ["devs", "ops"], // Optional
|
|
44
47
|
});
|
|
45
48
|
|
|
46
49
|
console.log(response.success);
|
|
@@ -49,6 +52,10 @@ console.log(response.devices_notified);
|
|
|
49
52
|
|
|
50
53
|
### Start a Live Activity
|
|
51
54
|
|
|
55
|
+
<p align="center">
|
|
56
|
+
<img src="https://cdn.activitysmith.com/features/start-live-activity.png" alt="Start live activity example" width="680" />
|
|
57
|
+
</p>
|
|
58
|
+
|
|
52
59
|
```ts
|
|
53
60
|
const start = await activitysmith.liveActivities.start({
|
|
54
61
|
content_state: {
|
|
@@ -67,6 +74,10 @@ const activityId = start.activity_id;
|
|
|
67
74
|
|
|
68
75
|
### Update a Live Activity
|
|
69
76
|
|
|
77
|
+
<p align="center">
|
|
78
|
+
<img src="https://cdn.activitysmith.com/features/update-live-activity.png" alt="Update live activity example" width="680" />
|
|
79
|
+
</p>
|
|
80
|
+
|
|
70
81
|
```ts
|
|
71
82
|
const update = await activitysmith.liveActivities.update({
|
|
72
83
|
activity_id: activityId,
|
|
@@ -82,6 +93,10 @@ console.log(update.devices_notified);
|
|
|
82
93
|
|
|
83
94
|
### End a Live Activity
|
|
84
95
|
|
|
96
|
+
<p align="center">
|
|
97
|
+
<img src="https://cdn.activitysmith.com/features/end-live-activity.png" alt="End live activity example" width="680" />
|
|
98
|
+
</p>
|
|
99
|
+
|
|
85
100
|
```ts
|
|
86
101
|
const end = await activitysmith.liveActivities.end({
|
|
87
102
|
activity_id: activityId,
|
|
@@ -96,6 +111,48 @@ const end = await activitysmith.liveActivities.end({
|
|
|
96
111
|
console.log(end.success);
|
|
97
112
|
```
|
|
98
113
|
|
|
114
|
+
## Channels
|
|
115
|
+
|
|
116
|
+
Channels are used to target specific team members or devices. Can be used for both push notifications and live activities.
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
const response = await activitysmith.notifications.send({
|
|
120
|
+
title: "New subscription 💸",
|
|
121
|
+
message: "Customer upgraded to Pro plan",
|
|
122
|
+
channels: ["sales", "customer-success"], // Optional
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Push Notification Redirection and Actions
|
|
127
|
+
|
|
128
|
+
Push notification redirection and actions are optional and can be used to redirect the user to a specific URL when they tap the notification or to trigger a specific action when they long-press the notification.
|
|
129
|
+
Webhooks are executed by ActivitySmith backend.
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
const response = await activitysmith.notifications.send({
|
|
133
|
+
title: "New subscription 💸",
|
|
134
|
+
message: "Customer upgraded to Pro plan",
|
|
135
|
+
redirection: "https://crm.example.com/customers/cus_9f3a1d", // Optional
|
|
136
|
+
actions: [
|
|
137
|
+
{
|
|
138
|
+
title: "Open CRM Profile",
|
|
139
|
+
type: "open_url",
|
|
140
|
+
url: "https://crm.example.com/customers/cus_9f3a1d",
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
title: "Start Onboarding Workflow",
|
|
144
|
+
type: "webhook",
|
|
145
|
+
url: "https://hooks.example.com/activitysmith/onboarding/start",
|
|
146
|
+
method: "POST",
|
|
147
|
+
body: {
|
|
148
|
+
customer_id: "cus_9f3a1d",
|
|
149
|
+
plan: "pro",
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
], // Optional (max 4)
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
99
156
|
## Error Handling
|
|
100
157
|
|
|
101
158
|
```ts
|
|
@@ -108,11 +165,6 @@ try {
|
|
|
108
165
|
}
|
|
109
166
|
```
|
|
110
167
|
|
|
111
|
-
## API Surface
|
|
112
|
-
|
|
113
|
-
- `activitysmith.notifications`
|
|
114
|
-
- `activitysmith.liveActivities`
|
|
115
|
-
|
|
116
168
|
## TypeScript Support
|
|
117
169
|
|
|
118
170
|
This package is written in TypeScript and ships with type definitions out of the box.
|
|
@@ -19,12 +19,12 @@ export interface SendPushNotificationRequest {
|
|
|
19
19
|
*/
|
|
20
20
|
export declare class PushNotificationsApi extends runtime.BaseAPI {
|
|
21
21
|
/**
|
|
22
|
-
* Sends a push notification to devices matched by API key scope and optional target channels.
|
|
22
|
+
* Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL (tap) and up to 4 interactive actions (long-press on iOS).
|
|
23
23
|
* Send a push notification
|
|
24
24
|
*/
|
|
25
25
|
sendPushNotificationRaw(requestParameters: SendPushNotificationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<PushNotificationResponse>>;
|
|
26
26
|
/**
|
|
27
|
-
* Sends a push notification to devices matched by API key scope and optional target channels.
|
|
27
|
+
* Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL (tap) and up to 4 interactive actions (long-press on iOS).
|
|
28
28
|
* Send a push notification
|
|
29
29
|
*/
|
|
30
30
|
sendPushNotification(requestParameters: SendPushNotificationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<PushNotificationResponse>;
|
|
@@ -20,7 +20,7 @@ const runtime = require("../runtime");
|
|
|
20
20
|
*/
|
|
21
21
|
class PushNotificationsApi extends runtime.BaseAPI {
|
|
22
22
|
/**
|
|
23
|
-
* Sends a push notification to devices matched by API key scope and optional target channels.
|
|
23
|
+
* Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL (tap) and up to 4 interactive actions (long-press on iOS).
|
|
24
24
|
* Send a push notification
|
|
25
25
|
*/
|
|
26
26
|
async sendPushNotificationRaw(requestParameters, initOverrides) {
|
|
@@ -47,7 +47,7 @@ class PushNotificationsApi extends runtime.BaseAPI {
|
|
|
47
47
|
return new runtime.JSONApiResponse(response);
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* Sends a push notification to devices matched by API key scope and optional target channels.
|
|
50
|
+
* Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL (tap) and up to 4 interactive actions (long-press on iOS).
|
|
51
51
|
* Send a push notification
|
|
52
52
|
*/
|
|
53
53
|
async sendPushNotification(requestParameters, initOverrides) {
|
|
@@ -557,6 +557,55 @@ export interface NoRecipientsError {
|
|
|
557
557
|
*/
|
|
558
558
|
effective_channel_slugs?: Array<string>;
|
|
559
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
*
|
|
562
|
+
* @export
|
|
563
|
+
* @interface PushNotificationAction
|
|
564
|
+
*/
|
|
565
|
+
export interface PushNotificationAction {
|
|
566
|
+
[key: string]: any | any;
|
|
567
|
+
/**
|
|
568
|
+
* Button title displayed in iOS expanded notification UI.
|
|
569
|
+
* @type {string}
|
|
570
|
+
* @memberof PushNotificationAction
|
|
571
|
+
*/
|
|
572
|
+
title: string;
|
|
573
|
+
/**
|
|
574
|
+
*
|
|
575
|
+
* @type {PushNotificationActionType}
|
|
576
|
+
* @memberof PushNotificationAction
|
|
577
|
+
*/
|
|
578
|
+
type: PushNotificationActionType;
|
|
579
|
+
/**
|
|
580
|
+
* HTTPS URL. For open_url it is opened in browser. For webhook it is called by ActivitySmith backend.
|
|
581
|
+
* @type {string}
|
|
582
|
+
* @memberof PushNotificationAction
|
|
583
|
+
*/
|
|
584
|
+
url: string;
|
|
585
|
+
/**
|
|
586
|
+
* Webhook HTTP method. Used only when type=webhook.
|
|
587
|
+
* @type {PushNotificationWebhookMethod}
|
|
588
|
+
* @memberof PushNotificationAction
|
|
589
|
+
*/
|
|
590
|
+
method?: PushNotificationWebhookMethod;
|
|
591
|
+
/**
|
|
592
|
+
* Optional webhook payload body. Used only when type=webhook.
|
|
593
|
+
* @type {{ [key: string]: any; }}
|
|
594
|
+
* @memberof PushNotificationAction
|
|
595
|
+
*/
|
|
596
|
+
body?: {
|
|
597
|
+
[key: string]: any;
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
*
|
|
602
|
+
* @export
|
|
603
|
+
*/
|
|
604
|
+
export declare const PushNotificationActionType: {
|
|
605
|
+
readonly OpenUrl: "open_url";
|
|
606
|
+
readonly Webhook: "webhook";
|
|
607
|
+
};
|
|
608
|
+
export type PushNotificationActionType = typeof PushNotificationActionType[keyof typeof PushNotificationActionType];
|
|
560
609
|
/**
|
|
561
610
|
*
|
|
562
611
|
* @export
|
|
@@ -582,6 +631,18 @@ export interface PushNotificationRequest {
|
|
|
582
631
|
* @memberof PushNotificationRequest
|
|
583
632
|
*/
|
|
584
633
|
subtitle?: string;
|
|
634
|
+
/**
|
|
635
|
+
* Optional HTTPS URL opened when user taps the notification body.
|
|
636
|
+
* @type {string}
|
|
637
|
+
* @memberof PushNotificationRequest
|
|
638
|
+
*/
|
|
639
|
+
redirection?: string;
|
|
640
|
+
/**
|
|
641
|
+
* Optional interactive actions shown on iOS long-press.
|
|
642
|
+
* @type {Array<PushNotificationAction>}
|
|
643
|
+
* @memberof PushNotificationRequest
|
|
644
|
+
*/
|
|
645
|
+
actions?: Array<PushNotificationAction>;
|
|
585
646
|
/**
|
|
586
647
|
*
|
|
587
648
|
* @type {{ [key: string]: any; }}
|
|
@@ -647,6 +708,15 @@ export interface PushNotificationResponse {
|
|
|
647
708
|
*/
|
|
648
709
|
timestamp: string;
|
|
649
710
|
}
|
|
711
|
+
/**
|
|
712
|
+
*
|
|
713
|
+
* @export
|
|
714
|
+
*/
|
|
715
|
+
export declare const PushNotificationWebhookMethod: {
|
|
716
|
+
readonly Get: "GET";
|
|
717
|
+
readonly Post: "POST";
|
|
718
|
+
};
|
|
719
|
+
export type PushNotificationWebhookMethod = typeof PushNotificationWebhookMethod[keyof typeof PushNotificationWebhookMethod];
|
|
650
720
|
/**
|
|
651
721
|
*
|
|
652
722
|
* @export
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContentStateUpdateStepColorEnum = exports.ContentStateUpdateColorEnum = exports.ContentStateStartStepColorEnum = exports.ContentStateStartColorEnum = exports.ContentStateStartTypeEnum = exports.ContentStateEndStepColorEnum = exports.ContentStateEndColorEnum = void 0;
|
|
3
|
+
exports.PushNotificationWebhookMethod = exports.PushNotificationActionType = exports.ContentStateUpdateStepColorEnum = exports.ContentStateUpdateColorEnum = exports.ContentStateStartStepColorEnum = exports.ContentStateStartColorEnum = exports.ContentStateStartTypeEnum = exports.ContentStateEndStepColorEnum = exports.ContentStateEndColorEnum = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @export
|
|
6
6
|
*/
|
|
@@ -91,3 +91,19 @@ exports.ContentStateUpdateStepColorEnum = {
|
|
|
91
91
|
Orange: 'orange',
|
|
92
92
|
Yellow: 'yellow'
|
|
93
93
|
};
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @export
|
|
97
|
+
*/
|
|
98
|
+
exports.PushNotificationActionType = {
|
|
99
|
+
OpenUrl: 'open_url',
|
|
100
|
+
Webhook: 'webhook'
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
* @export
|
|
105
|
+
*/
|
|
106
|
+
exports.PushNotificationWebhookMethod = {
|
|
107
|
+
Get: 'GET',
|
|
108
|
+
Post: 'POST'
|
|
109
|
+
};
|