Skip to main content

Gift widget

The Gift Widget allows users to give each other gifts in the form of badges and/or points. Using this widget, one user can give another any of the Gifts or Giftable Points configured in the Administration Panel.

Gift widget interface for sending rewards to other users The Gift Widget interface allowing users to select recipients, gift types, and add personalized messages

Implementation

To render the Gift Widget, add a call to the Mambo gift() function in the mamboCallbacks() array. The example below shows the function call with all available options. None of these options are required, so you could simply use: Mambo('.selector').gift().

JavaScript

Configuration options

Each option found in the code above is explained in detail below. None of these options are required.

Display options

OptionDescriptionDefault ValueSample Value
popupWhen enabled, displays the widget in a popup in the middle of the screen. When using this option, a class selector is not required.falsetrue
titleAllows you to override the default title displayed in the widget.nullSend a Gift
prizeAdds a prize message under the widget title. This can be used to describe an activity triggered by the triggerActivity option, providing users with additional incentive to give gifts.nullWin 600 points

Gift content options

OptionDescriptionDefault ValueSample Value
withPointsEnables or disables the option to give points through the widget.truefalse
withGiftsEnables or disables the option to give Gift rewards through the widget.truefalse
requireReasonDetermines whether the reason field ("Tell them why") is mandatory when sending a gift.truefalse

User filtering options

OptionDescriptionDefault ValueSample Value
tagsSpecifies tags that users must have in order to appear in the search results. This allows you to focus gifting on particular subsets of users, such as members of a specific department or office location.null['finance_dept','hr_dept']
tagsJoinDetermines whether users must have all specified tags (hasAllOf) or any of the specified tags (hasAnyOf) to appear in search results.hasAnyOfhasAllOf

Activity triggers

OptionDescriptionDefault ValueSample Value
triggerActivityDefines an activity that will be triggered for the user who performs the gifting. This allows you to reward the sender with any type of activity (behaviour, point, coupon, etc). See Create activities for sample data objects.nullSee activities documentation

User data options

A user with no name is still listed as someone you can give a gift to, under the Anonymous label. Supply your own names and pictures with these options, or with the users options if every widget on the page should draw on the same source.

OptionDescriptionDefault ValueSample Value
userSearchFunction searching your own users, in place of Mambo's search. Mambo matches on the names it holds, so a site which has not shared them finds nobody and cannot give a gift at all.nullfunction(query, ctx) { ... }
userResolverFunction supplying the details of the users the search found.nullfunction(uuids, ctx) { ... }
userDataA map of uuid to user details, used in place of a resolver when the data is already on the page.null{'0001': {firstName: 'Ana'}}

Searching your own users

Return whatever users match the query, each carrying at least a uuid. The gift is sent to the uuid, so you are free to name them however you like.

JavaScript
Gifts you have received

The message naming who gave you a gift keeps a record of the giver taken at the moment of the gift, and that record does not carry the uuid your resolver and search are keyed on. A gift from a user who has no name in Mambo therefore shows as Anonymous, and cannot presently be corrected by supplying your own data.