Goals

SDK platic.campaigns.goals.list()
SDK platic.campaigns.goals.create()
SDK platic.campaigns.goals.update()

A goal defines what should happen in a campaign conversation, such as "Asked for a quote". The report counts conversations that meet the criteria.

Before you start: the campaign id in the CAMPAIGN_ID variable.

Create a goal

const campaignId = process.env.CAMPAIGN_ID!;
const goal = await platic.campaigns.goals.create(campaignId, {
  name: "Asked for a quote",
  criteria: "The customer asks for a price.",
});

If a goal with that name already exists, the response is 200 with that goal and alreadyExisted: true. Update that goal to change its criteria.

List reference

ParameterInTypeDescriptionRequired
campaignIdpathstringThe campaign id✓
workspacequerystringThe campaign's workspace, if the credential covers several—

data carries all the campaign's goals, without pagination:

{
  "status": "success",
  "data": [
    { "id": "gq3Lm8Xp", "name": "Asked for a quote", "criteria": "The customer asks for a price.", "status": "active" }
  ]
}
Statusdetails.codeWhen
400INVALID_REQUESTThe credential covers several workspaces and workspace is missing or is not one of them

See Errors for the full shape of an error.

Create reference

FieldTypeDescriptionRequired
namestringA short, clear name, up to 120 characters✓
criteriastringHow you can tell in the conversation that it was achieved, up to 2,000 characters✓

It answers 201 with the new goal, or 200 with the one that already existed:

{
  "status": "success",
  "message": "Goal created",
  "data": {
    "id": "gq3Lm8Xp",
    "name": "Asked for a quote",
    "criteria": "The customer asks for a price.",
    "status": "active",
    "alreadyExisted": false
  }
}

Update reference

Send name, criteria, or both, using the same limits as for creation. Get the goalId by listing goals. The response contains the updated goal.

Statusdetails.codeWhen
400—Neither name nor criteria arrived, or they go over the limit
404GOAL_NOT_FOUNDThe campaign has no goal with that id