GraphQL Examples

The GraphQL interface permits you to create, maintain and edit your models programmatically. The following are pieces of example GraphQL that you can copy to help you perform various tasks.

Queries

Viewing a list of rulesets

{
  rulesets
  {
    name
  }
}

Viewing a list of Machine learning models

{
  mlmodels
  {
    name
  }
}

Finding your API key

{
  getApiKey
}

listing collateral

{
 collateral
  {
    name
    value
  }
}

Seeing the language elements set in a ruleset

{
  rulesetByName(name: "military_service.rule")
  {
    ruleform
    {
      language
      {
        languageList
        {
          name
          text
        }
      }
    }
  }
}

See a list of preloaded data items in a rule set

{
  rulesetByName(name: "military_service.rule")
  {
    ruleform{
      preload{
        name
        dataType
        value
      }
    }
  }
}

Start a questionnaire

{
  beginQuestionnaire(ruleSetName: "military_service.rule")
  {
    ieToken
    questionHeader
    values
    {
      name
      value
    }
    questions
    {
      text
      categories
      reference
      qType
    }
    responses
    {
      responseType
      mainText
      annotation
    }
  }
}

Continue a questionnaire

{
  continueQuestionnaire(responses:{
     ieToken: "<ieToken value returned by begin questionnaire>",
    questions:
    [
    {
      reference: "name",
      sResponse: "Yes",
      qType: textual
    }
  ]
  })
  {
    complete
    ieToken
    questionHeader
    values
    {
      name
      value
    }
    questions
    {
      text
      categories
      reference
      qType
    }
    responses
    {
      mainText
      annotation
    }
  }
}

Interact with a Bot

query interact($model: String!, $convId: String!, $data: darlVarUpdate!)
{
  interact(botModelName: $model, conversationId: $convId, conversationData: $data)
  {
    response
    {
      value
      dataType
      categories
    }
  }
}

Get lineages for a word

{
  getLineagesForWord(word: "immigration")
  {
    description
    lineage
    typeWord
  }
}

Mutations

Setting the text for a ruleset question

mutation{
  updateRuleSetLanguageText(ruleSetName: "military_service.rule", 
    languageName: "military", languageText: "Did you serve in the US military?")
  {
    name
    text
  }
}

Setting a preloaded data value for a rule set

mutation{
  updateRulesetPreload(rulesetName: "military_service.rule", preloadData: 
    { name: "comply_text", dataType:  textual, value: "Thanks, that looks great. Expect an email in the near future."
  })
  {
    name
    value
  }
}

Run a machine learning model

mutation
{
  machineLearnModel(mlmodelname: "iris.mlmodel")
  {
    results{
      trainPerformance
      code
    }
  }
}

Factory reset - Dangerous!

mutation
{
  factoryReset
}

Update the DARL code in a rulesset

mutation
{
  updateRuleSetDarl(name: "military_service.rule", darl: "ruleset military_service {} ")
  {
    name
  }
}

Update SendGrid credentials

mutation
{
  updateSendgridCredentials(botModelName: "thousandquestions.model", 
    sendGridAPIKey: "SG.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
  {
    sendGridAPIKey
  }
}

Add a phrase to botmodel

mutation
{
  createPhrase(botModelName: "thousandquestions.model",
    path: "verb:067,4,0|noun:01,0,2,00,00,15,20,19,1",
    attribute: {
      call: "military_service.rule"
    }
  )
  {
    darl
  }
}

Update a ruleset trigger

mutation
{
  updateRuleSetTrigger(ruleSetName: "military_service.rule", trigger: {
    sendEmailSource: RESULTS,
    sendEmail: "trigger.true",
    addressSource: FIXED,
    addressText: "andy@darl.ai",
    emailFrom: "support@darl.ai",
    subjectSource: FIXED,
    subjectText: "Application on website" ,
    bodySource: RESULTS,
    bodyText: "emailText"
  })
  {
    sendEmail
  }
}

exclude a Ruleset output from the visible results

mutation
{
 updateRuleSetOutputFormat(ruleSetName: "military_service.rule", outputName: "emailText", outputUpdate:
  {
    hide: true
  })
  {
    hide
  }
}