menu button

Optional calls

Assign Textsegments to Agenda Item

Assign Textsegments to Agenda Item

Use the assignTextsegmentsToAgendaItem mutation to reassign a block of transcript segments to a (typically empty) agenda item.

You pass the agenda item you want to fill and exactly one boundary segment — either the segment that should become the target item’s first segment (firstTextsegmentId, forward) or the one that should become its last segment (lastTextsegmentId, backward). The mutation then walks away from that boundary and pulls in all consecutive segments from the same source:

  • Forward (firstTextsegmentId): the boundary becomes the first segment, and the walk goes forward from it.
  • Backward (lastTextsegmentId): the boundary becomes the last segment, and the walk goes backward, pulling in all preceding segments of the same source.

“Same source” behaves identically in both directions:

  • If the boundary segment currently belongs to another agenda item, all consecutive segments of that item up to (backward) or from (forward) the boundary are moved over.
  • If the boundary segment is currently unassigned, all consecutive unassigned segments are moved over — stopping as soon as a segment already owned by another item is encountered.

Provide either firstTextsegmentId or lastTextsegmentId, never both and never neither — otherwise the mutation returns an error.

The boundary segment must belong to the same protocol as the target agenda item.


GraphQL Mutation

fragment moveAgendaItemDetails on MoveAgendaItemResultItemType {
  id
  title
  textsegments {
    id
    pos
    agendaItemId
    speakerObj {
      slug
      givenName
      familyName
      gender
      party
      preTitle
      postTitle
      posShort
      posLong
      specialCase
    }
    textJson {
      text
      startTime
      endTime
    }
  }
}

# Provide exactly one of firstTextsegmentId (forward) or lastTextsegmentId (backward).
mutation AssignTextsegmentsToAgendaItem(
  $agendaItemId: Int!
  $firstTextsegmentId: Int
  $lastTextsegmentId: Int
) {
  assignTextsegmentsToAgendaItem(
    agendaItemId: $agendaItemId
    firstTextsegmentId: $firstTextsegmentId
    lastTextsegmentId: $lastTextsegmentId
  ) {
    success
    agendaItemList {
      ...moveAgendaItemDetails
    }
  }
}

Mutation Variables

Forward — fill the target item starting at the given segment:

{
  "agendaItemId": 42,
  "firstTextsegmentId": 187
}

Backward — fill the target item ending at the given segment:

{
  "agendaItemId": 42,
  "lastTextsegmentId": 187
}
  • agendaItemId (Int, required) — ID of the agenda item to assign segments to. Typically an empty item returned by getResultsWithEmpty.
  • firstTextsegmentId (Int, optional) — ID of the segment that becomes the first segment of the target item. The walk goes forward; all eligible consecutive segments from this point are reassigned automatically.
  • lastTextsegmentId (Int, optional) — ID of the segment that becomes the last segment of the target item. The walk goes backward; all eligible consecutive segments up to this point are reassigned automatically.

Provide exactly one of firstTextsegmentId or lastTextsegmentId.


Example JavaScript Implementation

import axios from "axios";

const ASSIGN_TEXTSEGMENTS_TO_AGENDA_ITEM = `
  fragment moveAgendaItemDetails on MoveAgendaItemResultItemType {
    id
    title
    textsegments {
      id
      pos
      speakerObj {
        slug
        givenName
        familyName
      }
      textJson {
        text
        startTime
        endTime
      }
    }
  }

  # Provide exactly one of firstTextsegmentId (forward) or lastTextsegmentId (backward).
  mutation AssignTextsegmentsToAgendaItem(
    $agendaItemId: Int!
    $firstTextsegmentId: Int
    $lastTextsegmentId: Int
  ) {
    assignTextsegmentsToAgendaItem(
      agendaItemId: $agendaItemId
      firstTextsegmentId: $firstTextsegmentId
      lastTextsegmentId: $lastTextsegmentId
    ) {
      success
      agendaItemList {
        ...moveAgendaItemDetails
      }
    }
  }
`;

// Pass exactly one of { firstTextsegmentId } or { lastTextsegmentId }.
export async function assignTextsegmentsToAgendaItem(agendaItemId, { firstTextsegmentId, lastTextsegmentId } = {}) {
  const res = await axios.post(
    "https://api-v2.speechmind.com/external/v2/graphql",
    {
      query: ASSIGN_TEXTSEGMENTS_TO_AGENDA_ITEM,
      variables: { agendaItemId, firstTextsegmentId, lastTextsegmentId },
    },
    {
      headers: {
        "Content-Type": "application/json",
        "x-api-key": process.env.SPEECHMIND_API_KEY,
      },
    }
  );

  const { success, agendaItemList } = res.data.data.assignTextsegmentsToAgendaItem;
  return { success, agendaItemList };
}

// Example usage
assignTextsegmentsToAgendaItem(42, { firstTextsegmentId: 187 }); // forward
assignTextsegmentsToAgendaItem(42, { lastTextsegmentId: 187 });  // backward

Notes

  • The returned agendaItemList is of type MoveAgendaItemResultItemType — it contains id, title, and textsegments, not the AI-generated textList/texts fields. To retrieve the full content after reassignment, call getResults or getResultsWithEmpty.
  • Each text segment now exposes an agendaItemId field — the ID of the agenda item it belongs to, or null if the segment is not assigned to any agenda item. Query getTextsegmentsByProtocolAndPage and look for agendaItemId == null to find unassigned segments.
  • Use getResultsWithEmpty to discover empty agenda items and getTextsegmentsByProtocolAndPage to find the right boundary segment ID before calling this mutation.
  • Only segments that are consecutive and from the same source are moved. The walk stops at the first segment already belonging to a different agenda item.

Have questions?

Still have questions? Talk to support.