import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: 'My API Key',
});
const response = await client.ai.assistants.chat('assistant_id', {
content: 'Tell me a joke about cats',
conversation_id: '42b20469-1215-4a9a-8964-c36f66b406f4',
});
console.log(response.content);{
"content": "Why did the cat sit on the computer? Because it wanted to keep an eye on the mouse!"
}This endpoint allows a client to send a chat message to a specific AI Assistant. The assistant processes the message and returns a relevant reply based on the current conversation context. Refer to the Conversation API to create a conversation, filter existing conversations, fetch messages for a conversation, and manually add messages to a conversation.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: 'My API Key',
});
const response = await client.ai.assistants.chat('assistant_id', {
content: 'Tell me a joke about cats',
conversation_id: '42b20469-1215-4a9a-8964-c36f66b406f4',
});
console.log(response.content);{
"content": "Why did the cat sit on the computer? Because it wanted to keep an eye on the mouse!"
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
The message content sent by the client to the assistant
"Tell me a joke about cats"
A unique identifier for the conversation thread, used to maintain context
"42b20469-1215-4a9a-8964-c36f66b406f4"
The optional display name of the user sending the message
"Charlie"
Successful Response
The assistant's generated response based on the input message and context.
"Why did the cat sit on the computer? Because it wanted to keep an eye on the mouse!"
Was this page helpful?