Message Reactions API for PubNub Go SDK

Add or remove actions on published messages to build features like receipts, reactions, or to associate custom metadata to messages. Clients can subscribe to a channel to receive message action events on that channel. They can also fetch past message actions from Message Persistence independently or when they fetch original messages.

Add Message Reaction

Requires Message Persistence

This method requires that Message Persistence is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

Add an action on a published message. Returns the added action in the response.

Method(s)

To Add a Message Reaction you can use the following method(s) in the Go SDK:

pn.AddMessageAction().
Channel(string).
MessageTimetoken(string).
Action(pubnub.MessageAction).
Execute()
ParameterTypeRequiredDescription
ChannelstringYesThe channel name.
MessageTimetokenstringYesThe publish timetoken of a parent message.
Actionpubnub.MessageActionYesMessage Reaction Details :-ActionType: What feature this action represents -- max 15 characters. ActionValue: Details about the action -- max 40 characters.

Basic Usage

ma := pubnub.MessageAction{
ActionType: "reaction",
ActionValue: "smiley_face",
}

res, status, err := pn.AddMessageAction()
.Channel("my-channel")
.MessageTimetoken("15698453963258802")
.Action(ma)
.Execute()

Returns

The AddMessageAction() operation returns a PNAddMessageActionsResponse which contains the following parameters:

Property NameTypeDescription
DataPNMessageActionsResponseDetails of type PNMessageActionsResponse are here

PNMessageActionsResponse

Property NameTypeDescription
ActionTypestringWhat feature this action represents.
ActionValuestringDetails about the action.
ActionTimetokenstringThe timetoken when the action was added.
MessageTimetokenstringThe timetoken of the parent message.

Remove Message Reaction

Requires Message Persistence

This method requires that Message Persistence is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

Remove a previously added action on a published message. Returns an empty response.

Method(s)

To Remove a Message Reaction you can use the following method(s) in the Go SDK:

pn.RemoveMessageAction().
Channel(string).
MessageTimetoken(string).
ActionTimetoken(string).
Execute()
ParameterTypeRequiredDescription
ChannelstringYesThe channel name.
MessageTimetokenstringYesThe publish timetoken of a parent message.
ActionTimetokenstringYesThe publish timetoken of the action.

Basic Usage

res, status, err := pn.RemoveMessageAction()
.Channel("my-channel")
.MessageTimetoken("15698453963258802")
.ActionTimetoken("15698453963258812")
.Execute()

Returns

The RemoveMessageAction() operation returns a PNRemoveMessageActionsResponse which contains the following parameters:

Property NameTypeDescription
DatainterfaceReturns an empty interface.

Get Message Reactions

Requires Message Persistence

This method requires that Message Persistence is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

Get a list of message actions in a channel. Returns a list of actions sorted by the action's timetoken in ascending order.

Truncated response

Number of message actions in the response may be truncated when internal limits are hit. If the response is truncated, a more property will be returned with additional parameters. Send iterative calls to Message Persistence adjusting the parameters to fetch more message actions.

Method(s)

To Get Message Reactions you can use the following method(s) in the Go SDK:

pn.GetMessageActions().
Channel(string).
Start(string).
End(string).
Limit(int).
Execute()
ParameterTypeRequiredDescription
ChannelstringYesThe channel name.
StartstringOptionalAction timetoken denoting the start of the range requested (return values will be less than start).
EndstringOptionalAction timetoken denoting the end of the range requested (return values will be greater than or equal to end).
LimitintOptionalNumber of actions to return in response..

Basic Usage

res, status, err := pn.GetMessageActions()
.Channel("my-channel")
.Start("15698453963258812")
.End("15698453963258811")
.Execute()

Returns

The GetMessageActions() operation returns a PNGetMessageActionsResponse which contains the following parameters:

Property NameTypeDescription
Data[]PNMessageActionsResponseDetails of type PNMessageActionsResponse are here
MorePNGetMessageActionsMoreDetails of type PNGetMessageActionsMore are here

PNGetMessageActionsMore

Property NameTypeDescription
URLstringThe URL of the next set of results.
StartstringThe start param for the next set of results.
EndstringThe end param for the next set of results.
LimitintThe limit for the next set of results.
Last updated on