Skip to main content
POST
/
ai
/
conversations
/
{conversation_id}
/
message
JavaScript
import Telnyx from 'telnyx';

const client = new Telnyx({
  apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});

await client.ai.conversations.addMessage('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { role: 'role' });
import os
from telnyx import Telnyx

client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
client.ai.conversations.add_message(
conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
role="role",
)
package main

import (
"context"

"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)

func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.AI.Conversations.AddMessage(
context.TODO(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.AIConversationAddMessageParams{
Role: "role",
},
)
if err != nil {
panic(err.Error())
}
}
package com.telnyx.sdk.example;

import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.ai.conversations.ConversationAddMessageParams;

public final class Main {
private Main() {}

public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();

ConversationAddMessageParams params = ConversationAddMessageParams.builder()
.conversationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
.role("role")
.build();
client.ai().conversations().addMessage(params);
}
}
require "telnyx"

telnyx = Telnyx::Client.new(api_key: "My API Key")

result = telnyx.ai.conversations.add_message("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", role: "role")

puts(result)
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;

$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');

try {
$result = $client->ai->conversations->addMessage(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
role: 'role',
content: 'content',
metadata: ['foo' => 'string'],
name: 'name',
sentAt: new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
toolCallID: 'tool_call_id',
toolCalls: [['foo' => 'bar']],
toolChoice: 'string',
);

var_dump($result);
} catch (APIException $e) {
echo $e->getMessage();
}
telnyx ai:conversations add-message \
--api-key 'My API Key' \
--conversation-id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e \
--role role
curl --request POST \
--url https://api.telnyx.com/v2/ai/conversations/{conversation_id}/message \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"role": "<string>",
"content": "",
"name": "<string>",
"tool_choice": "<string>",
"tool_calls": [
{}
],
"tool_call_id": "<string>",
"sent_at": "2023-11-07T05:31:56Z",
"metadata": {}
}
'
{
  "detail": [
    {
      "loc": [
        "<string>"
      ],
      "msg": "<string>",
      "type": "<string>"
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

conversation_id
string<uuid>
required

The ID of the conversation

Body

application/json
role
string
required
content
string
default:""
name
string
tool_choice
tool_calls
Tool Calls · object[]
tool_call_id
string
sent_at
string<date-time>
metadata
Metadata · object

Response

Successful Response