The ActivitySmith Go SDK provides convenient access to the ActivitySmith API from Go applications.
See API reference.
go get github.com/ActivitySmithHQ/activitysmith-gopackage main
import (
"log"
activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go"
"github.com/ActivitySmithHQ/activitysmith-go/generated"
)
func main() {
activitysmith, err := activitysmithsdk.New("YOUR_API_KEY")
if err != nil {
log.Fatal(err)
}
input := activitysmithsdk.PushNotificationInput{
Title: "New subscription ๐ธ",
Message: "Customer upgraded to Pro plan",
}
response, err := activitysmith.Notifications.
Send(input)
if err != nil {
log.Fatal(err)
}
log.Println("Notified:", response.GetDevicesNotified())
}Use activitysmith.Notifications.Send with either activitysmithsdk.PushNotificationInput (basic) or generated.PushNotificationRequest (advanced fields like redirection and actions).
input := activitysmithsdk.PushNotificationInput{
Title: "New subscription ๐ธ",
Message: "Customer upgraded to Pro plan",
}
response, err := activitysmith.Notifications.Send(input)
if err != nil {
log.Fatal(err)
}
log.Println(response.GetSuccess())
log.Println(response.GetDevicesNotified())Use activitysmith.LiveActivities.Start with an activitysmithsdk.LiveActivityStartInput.
startInput := activitysmithsdk.LiveActivityStartInput{
Title: "Nightly database backup",
Subtitle: "create snapshot",
NumberOfSteps: 3,
CurrentStep: 1,
Type: "segmented_progress",
Color: "yellow",
Channels: []string{"devs", "ops"}, // Optional
}
start, err := activitysmith.LiveActivities.
Start(startInput)
if err != nil {
log.Fatal(err)
}
activityID := start.GetActivityId()Use activitysmith.LiveActivities.Update with the activityID from Start.
updateInput := activitysmithsdk.LiveActivityUpdateInput{
ActivityID: activityID,
Title: "Nightly database backup",
Subtitle: "upload archive",
CurrentStep: 2,
}
update, err := activitysmith.LiveActivities.
Update(updateInput)
if err != nil {
log.Fatal(err)
}
log.Println(update.GetDevicesNotified())Use activitysmith.LiveActivities.End to end the activity.
If AutoDismissMinutes is omitted, backend default 3 is used.
endInput := activitysmithsdk.LiveActivityEndInput{
ActivityID: activityID,
Title: "Nightly database backup",
Subtitle: "verify restore",
CurrentStep: 3,
AutoDismissMinutes: 2,
}
end, err := activitysmith.LiveActivities.
End(endInput)
if err != nil {
log.Fatal(err)
}
log.Println(end.GetSuccess())Channels are used to target specific team members or devices. Can be used for both push notifications and live activities.
request := generated.NewPushNotificationRequest("New subscription ๐ธ")
request.SetMessage("Customer upgraded to Pro plan")
request.SetTarget(generated.ChannelTarget{Channels: []string{"sales", "customer-success"}}) // Optional
response, err := activitysmith.Notifications.Send(request)
if err != nil {
log.Fatal(err)
}
log.Println(response.GetSuccess())
log.Println(response.GetDevicesNotified())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. Webhooks are executed by ActivitySmith backend.
request := generated.NewPushNotificationRequest("New subscription ๐ธ")
request.SetMessage("Customer upgraded to Pro plan")
request.SetRedirection("https://crm.example.com/customers/cus_9f3a1d") // Optional
crmAction := generated.NewPushNotificationAction(
"Open CRM Profile",
generated.PUSHNOTIFICATIONACTIONTYPE_OPEN_URL,
"https://crm.example.com/customers/cus_9f3a1d",
)
onboardingAction := generated.NewPushNotificationAction(
"Start Onboarding Workflow",
generated.PUSHNOTIFICATIONACTIONTYPE_WEBHOOK,
"https://hooks.example.com/activitysmith/onboarding/start",
)
onboardingAction.SetMethod(generated.PUSHNOTIFICATIONACTIONMETHOD_POST)
onboardingAction.SetBody(map[string]interface{}{
"customer_id": "cus_9f3a1d",
"plan": "pro",
})
request.SetActions([]generated.PushNotificationAction{
*crmAction,
*onboardingAction,
}) // Optional (max 4)
response, err := activitysmith.Notifications.Send(request)
if err != nil {
log.Fatal(err)
}
log.Println(response.GetSuccess())
log.Println(response.GetDevicesNotified())SDK methods return (response, error). Always check error on each call.
- Go 1.22+
MIT



