Bot Definition API 400 Bad Request on Terraform Apply with AI Bot

Could someone clarify why the genesyscloud_ai_bot resource fails with a 400 error during terraform apply?

The error message states: Invalid bot definition structure. Missing required field 'nluModelId' in training data configuration.

Environment:

  • Provider: genesyscloud 2.18.1
  • Region: ap-southeast-2
  • Terraform: 1.7.0

The HCL block looks correct based on the Genesys Docs.

resource "genesyscloud_ai_bot" "test_bot" {
 name = "Terraform-Bot-Test"
 description = "Automated deployment test"
 
 bot_definition = jsonencode({
 "nluModelId" = "${data.genesyscloud_nlu_model.default.id}",
 "trainingData" = [
 {
 "intentName" = "greeting",
 "phrases" = ["hello", "hi"]
 }
 ]
 })
}

The nluModelId is populated correctly during the plan phase. The API call to POST /api/v2/bots/ai returns the 400 status. Manual creation via UI works fine with same parameters. Is there a schema mismatch in the provider version? Or a specific JSON structure requirement for the bot_definition field that is not documented?

Using GitHub Actions for deployment. Logs show the payload is valid JSON. No 429s or timeouts. Just straight 400. Appreciate any insights on the expected JSON payload structure for bot_definition.

The way I solve this is by ensuring the training_data object explicitly includes the nlu_model_id reference, as the API rejects implicit associations during IaC deployment. Try updating your HCL to match this structure:

{
 "training_data": {
 "nlu_model_id": "{{nlu_model_uuid}}"
 }
}

The root cause here is the strict schema validation in Genesys Cloud compared to the more forgiving Zendesk API. Adding the explicit nlu_model_id as suggested above fixed the 400 error for us during migration.