menu button

API process flow

Rename Speaker & Create Protocol

Rename Speakers in Text Segments

The following description is only nessessary for protocol type politics. If you created a protocol type of summary your next and final call would be getResults query.

Once the protocol has finished processing (status = true from getProtocolBySlug), the next step is to rename speakers in all text segments. This ensures that the final document has accurate speaker attributions.

Understanding the Data

For a deeper understand of the data see getProtocolBySlug query.

GraphQL Mutation

mutation RenameSpeakerInTextsegment(
  $protocolSlug: String!
  $speakerList: [SpeakerDataInput]!
) {
  renameSpeakerInTextsegment(
    protocolSlug: $protocolSlug
    speakerList: $speakerList
  ) {
    success
  }
}

Mutation Variables For each speaker, provide a SpeakerDataInput object with the oldSlug (existing speaker identifier) and updated speaker details:

{
  "protocolSlug": "PROTOCOL_SLUG",
  "speakerList": [
    {
      "oldSlug": "SPEAKER_SLUG",
      "gender": "m",
      "givenName": "Thomas",
      "familyName": "Müller",
      "party": "",
      "preTitle": "",
      "postTitle": "",
      "posShort": "",
      "posLong": "",
      "systemId": ""
    },
    {
      "oldSlug": "SPEAKER_SLUG",
      "gender": "m",
      "givenName": "Max",
      "familyName": "Mustermann",
      "party": "",
      "preTitle": "",
      "postTitle": "",
      "posShort": "",
      "posLong": "",
      "systemId": ""
    }
  ]
}

Tip: Use the speakerList and summaryPerSpeakerList from getProtocolBySlug to automatically build this array. You can also use speakerSuggestion for recommended names.

Example JavaScript Implementation

import axios from "axios";

export const RENAME_SPEAKER_MUTATION = `...`;

async function renameSpeakers(protocolSlug, speakerList) {
  try {
    const response = await axios({
      method: "POST",
      url: process.env.VUE_APP_GRAPHQL_API,
      headers: {
        "Content-Type": "application/json",
        "x-api-key": process.env.VUE_APP_API_KEY,
      },
      data: JSON.stringify({
        query: RENAME_SPEAKER_MUTATION,
        variables: { protocolSlug, speakerList },
      }),
    });

    const data = response.data.data.renameSpeakerInTextsegment;

    if (data.success) {
      console.log("✔️ Speakers successfully renamed!");
    } else {
      console.log("❌ Failed to rename speakers");
    }
  } catch (error) {
    console.error("Error renaming speakers:", error);
  }
}

// Example usage
const protocolSlug = "PROTOCOL_SLUG";
const speakerList = [
  { oldSlug: "SPEAKER_SLUG", gender: "m", givenName: "Thomas", familyName: "Müller", party: "", preTitle: "", postTitle: "", posShort: "", posLong: "", systemId: "" },
  { oldSlug: "SPEAKER_SLUG", gender: "m", givenName: "Max", familyName: "Mustermann", party: "", preTitle: "", postTitle: "", posShort: "", posLong: "", systemId: "" }
];

renameSpeakers(protocolSlug, speakerList);

Next Steps

After renaming speakers, the text segments are updated and all the detail depths of the protocol will be created. This process can take some time based on the duration of the audio file and the resulting amount of text.

Next step would be calling getResults query.

Have questions?

Still have questions? Talk to support.