FirstBatch
Search…
⌃K

Custom Persona

FirstBatch API provides a custom persona pipeline to create gates with multiple interests, traits and ranks with boolean logic.
Python
Node
from firstbatch import PersonaMap, PersonhoodMap, custom_persona_query
# Allow
group_1 = [PersonhoodMap["rank_3"], PersonaMap["Skin Care"]]
# or
group_2 = [PersonhoodMap["rank_2"], PersonaMap["Gourmet travels"]]
# Don't allow
not_group = [PersonaMap["Crypto Trading"]]
# Create logic
logic = custom_persona_query(or_groups=[group_1, group_2], not_group=not_group)
# create_custom_persona will return a new group_id
custom_group_id = fb.create_custom_persona(name="MyPersona", logic=logic)["data"]["group_id"]
const {FirstbatchClient, EventTypes, Gate, PersonaMap} = require('firstbatch');
const public_key = "YOUR_PUBLIC_KEY"
const secret = "YOUR_SECRET"
const firstbatch = new FirstbatchClient(public_key, secret)
async function addCustomPersona(){
await fb.auth()
// Allow
const group_1 = [PersonhoodMap["rank_3"], PersonaMap["Skin Care"]]
// or
const group_2 = [PersonhoodMap["rank_2"], PersonaMap["Gourmet travels"]]
// Don't allow
const not_group = [PersonaMap["Crypto Trading"]]
const logic = customPersonaQuery([group_1, group_2], not_group)
let customGroupId = await fb.createCustomPersona("MyPersona", logic)
customGroupId = customGroupId["data"]["group_id"]
}
createCustomPersona()
Once created a custom group with group_id:
Python
Node
event = fb.create_event(name="CustomPersonaEvent", event_type=EventTypes.INTEREST_GATED)
# Attach gate with custom group
event.attach_gate(Gate(group_id=custom_group_id))
fb.add_gate(event)
fb.boot_event(event)
const {FirstbatchClient, EventTypes, Gate} = require('firstbatch');
const public_key = "YOUR_PUBLIC_KEY"
const secret = "YOUR_SECRET"
const firstbatch = new FirstbatchClient(public_key, secret)
async function addCustomPersonaGate(){
await firstbatch.auth()
const event = await firstbatch.createEvent("CustomPersonaEvent", EventTypes.INTEREST_GATED)
// Attach gate with custom group id
await event.attachGate(new Gate(customGroupId))
await firstbatch.addGate(event)
}
addCustomPersonaGate()
This allows complete flexibility on persona data, allowing DApps to create data routes fitting their needs.
To get previously created custom personas:
Python
Node
# Get persona data
data = fb.get_custom_persona()["data"]
# read group_id and name of the first custom persona
group_id, name = data[0]["group_id"], data[0]["name"]
const {FirstbatchClient, EventTypes, Gate} = require('firstbatch');
const public_key = "YOUR_PUBLIC_KEY"
const secret = "YOUR_SECRET"
const firstbatch = new FirstbatchClient(public_key, secret)
async function getCustomPersona(){
await firstbatch.auth()
const data = await firstbatch.getCustomPersona()
const group_id = data[0]["group_id"]
const name = data[0]["name"]
}
getCustomPersona()