Process text

This section provides basic code samples that you can use to start processing your text with the Async API.


Submit text

To submit text to the Async API, use the POST <https://api.symbl.ai/v1/process/text> operation:

👍

Try our interactive examples!

We provide interactive versions of these code samples: curl, Node.js, Python

To get started with our code samples, see Set Up Your Test Environment.

ACCESS_TOKEN="<ACCESS_TOKEN>"
CONVERSATION_NAME="<NAME>"
read -r -d '' MESSAGES << EndOfMessages
[
  {
    "payload": {
      "content": "<MESSAGE>"
    }
  },
  {
    "payload": {
      "content": "<MESSAGE>"
    }
  },
  ...
]
EndOfMessages

curl \
--url "https://api.symbl.ai/v1/process/text" \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "name": "'"$CONVERSATION_NAME"'",
  "messages": '"$MESSAGES"'
}'
import fetch from 'node-fetch';

const accessToken = '<ACCESS_TOKEN>';
const symblaiParams = {
  'name': '<NAME>',
  'messages': [
    {
      "payload": {
        "content": "<MESSAGE>"
      }
    },
    {
      "payload": {
        "content": "<MESSAGE>"
      }
    },
    ...
  ]
}

const fetchResponse = await fetch('https://api.symbl.ai/v1/process/text', {
  method: 'post',
  body: JSON.stringify(symblaiParams),
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'Content-Type': 'application/json'
  }
});

const responseBody = await fetchResponse.json();

console.log(responseBody);
import requests

access_token = "<ACCESS_TOKEN>"
symblai_params = {
  "name": "<NAME>",
  "messages": [
    {
      "payload": {
        "content": "<MESSAGE>"
      }
    },
    {
      "payload": {
        "content": "<MESSAGE>"
      }
    },
    ...
  ]
}

headers = {
  "Authorization": "Bearer " + access_token,
  "Content-Type": "application/json"
}

response = requests.request(
  method="POST", 
  url="https://api.symbl.ai/v1/process/text",
  headers=headers,
  json=symblai_params
)

print(response.json())

Where:

  • <ACCESS_TOKEN> is a valid API access token.
  • <NAME> is the name of the conversation. For example, Business Meeting 2022-01-01. If no name is provided, the Async API sets the name to the conversation ID.
  • <MESSAGE> is the text that you want to process. The messages array requires at least one message represented as an object in the array. Each object in the messages array requires a payload object that contains a value for content.

For additional reference information, see Submit text.

To learn more about the optional parameters that you can apply to your request, see Async Feature Reference.


Append text

👍

Try our interactive examples!

We provide interactive versions of these code samples: curl, Node.js, Python

To get started with our code samples, see Set Up Your Test Environment.

ACCESS_TOKEN="<ACCESS_TOKEN>"
CONVERSATION_NAME="<NAME>"
CONVERSATION_ID="<CONVERSATION_ID>"
read -r -d '' MESSAGES << EndOfMessages
[
  {
    "payload": {
      "content": "<MESSAGE>"
    }
  },
  {
    "payload": {
      "content": "<MESSAGE>"
    }
  },
  ...
]
EndOfMessages

curl --request PUT \
--url "https://api.symbl.ai/v1/process/text/$CONVERSATION_ID" \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "name": "'"$CONVERSATION_NAME"'",
  "messages": '"$MESSAGES"'
}'
import fetch from 'node-fetch';

const accessToken = '<ACCESS_TOKEN>';
const conversationId = '<CONVERSATION_ID>'
const symblaiParams = {
  'name': '<NAME>',
  'messages': [
    {
      'payload': {
        'content": '<MESSAGE>'
      }
    },
    {
      'payload': {
        'content': '<MESSAGE>'
      }
    },
    ...
  ]
}

const fetchResponse = await fetch(`https://api.symbl.ai/v1/process/text/${conversationId}`, {
  method: 'put',
  body: JSON.stringify(symblaiParams),
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'Content-Type': 'application/json'
  }
});

const responseBody = await fetchResponse.json();

console.log(responseBody);
import requests

access_token = "<ACCESS_TOKEN>"
conversation_id = "<CONVERSATION_ID>"
symblai_params = {
  "name": "<NAME>",
  "messages": [
    {
      "payload": {
        "content": "<MESSAGE>"
      }
    },
    {
      "payload": {
        "content": "<MESSAGE>"
      }
    },
    ...
  ]
}

headers = {
  "Authorization": "Bearer " + access_token,
  "Content-Type": "application/json"
}

response = requests.request(
  method="PUT", 
  url="https://api.symbl.ai/v1/process/text/" + conversation_id,
  headers=headers,
  json=symblai_params
)

print(response.json())

Where:

  • <ACCESS_TOKEN> is a valid API access token.
  • <CONVERSATION_ID> is the ID of a conversation that you previously processed.
  • <NAME> is the name of the conversation. For example, Business Meeting 2022-01-01. If no name is provided, the Async API sets the name to the conversation ID.
  • <MESSAGE> is the text that you want to process. The messages array requires at least one message represented as an object in the array. Each object in the messages array requires a payload object that contains a value for content.

For additional reference information, see Append text to a conversation.

To learn more about the optional parameters that you can apply to your request, see Async Feature Reference.


Response

The Async API returns a common response for all submit and append requests. The following table describes the fields in the response.

FieldDescription
conversationIdThe unique identifier of a conversation that is submitted to the Async API. The conversation ID is critical for generating Conversation Intelligence.
jobIdThe unique identifier of the processing job. The job ID can be used to get the status of the job.

Example response

The following is an example of the common response for submit and append requests to the Async API.

{
  conversationId: '5784375198220288',
  jobId: 'cf4a68fe-225a-4946-9819-d961d7a31058'
}