menu button

Chapter 3: Edit and Save Document

Edit Speakers and Create Document

This API involves editing a speaker.


Once the protocol data is retrieved, the speakerList field (a JSON-stringified object) contains detailed timing and text segments for each speaker.

Example structure:

    {
        "speaker": "Lisa",
        "duration": 70.6725,
        "textsegment": [
            {
                "id": "1",
                "speaker": "Lisa",
                "textJson": [{"text": "Good morning.", "start_time": 1, "end_time": 3}, 
                                //...
                            ],
                "pos": 0
            },
            // ...
        ]
    }

textJson Explaination:

The textJson field is a JSON-stringified array of objects, each representing a sentence spoken by the speaker. It contains:

  • text: The sentence spoken.
  • start_time: When the sentence begins (in seconds).
  • end_time: When the sentence ends (in seconds).

After editing speaker names:

Example body of renameSpeakerInTextSegment mutation

    export const GET_PROTOCOL_BY_SLUG = `
        fragment textsegmentDetails on ApiTextsegmentType {
            id
            speaker
            textJson {
                text
                startTime
                endTime
            }
            pos
        }

        mutation RenameSpeakerInTextsegment($protocolSlug:String!, $speakerJson:[SpeakerInput!]!){
            renameSpeakerInTextsegment(protocolSlug:$protocolSlug, speakerJson:$speakerJson){
                success
                textsegmentsForRename{
                    ...textsegmentDetails
                }
            }
        }
    `

Parameters for renameSpeakerInTextsegment Mutation

Information about the parameters to be passed


1. protocolSlug

  • A unique identifier (slug) for the protocol (meeting or document) where you want to rename the speakers.
    • Example: protocolSlug: “team-meeting-april-2025”

2. speakerJSON

To rename speakers, provide a JSON with a speakerList array where each item has old (current name) and new (replacement name) fields.

  • The JSON structure must follow this exact format:

    speakerJSON: {
        "speakerList": [
            {
                "old": "Lisa",
                "new": "Michelle"
            },
            {
                "old": "John",
                "new": "Michael"
            }
        ]
    }

Example JS code

    import axios from "axios";

    async function renameSpeakerInTextsegment(protocolSlug, speakerJson) {
        const dataObj = {
            query: RENAME_SPEAKER_IN_TEXTSEGMENT,
            variables: {
            protocolSlug: protocolSlug,
            speakerJson: JSON.stringify(speakerJson),
            },
        };

        return await axios({
            method: "post",
            url: process.env.VUE_APP_GRAPHQL_API,
            data: JSON.stringify(dataObj),
            headers: {
                "Content-Type": "application/json",
                "x-api-key": process.env.VUE_APP_API_KEY,
            },
        })
        .then((response) => {
            const responseData = response.data.data.renameSpeakerInTextsegment.textsegmentsForRename
            // ...
            return responseData
        })
        .catch((error) => {
            console.log(error);
        })
    }
  • This updates the speaker names across all relevant textsegment entries.
  • It also creates the first level of document depth, allowing for initial processing or export. In the first step, the document is created with only one depth level. However, multiple depth levels are possible. To add more depths, you can use the updateAgendaItemById mutation to edit the depth at index 0. After that, follow the instructions in the next section of the documentation to continue adding further depth levels to the document.

This final step ensures that all speaker attributions are correct and the protocol is ready for downstream use or publication.

Have questions?

Still have questions? Talk to support.