https://retellai.com/?utm_source=discord&utm_medium=seo logo
Is there anyway to jump into a chat and insert a m...
# ❓・ai-evy-support
s
@AI Evy Is there anyway to jump into a chat and insert a message manually?
a
Thanks for tagging me @summerpuppet471. I'll look through relevant sources and get back to you shortly.
### Answer Yes, you can insert a message into an ongoing chat using the Create Chat Completion endpoint. [(1) ]() This allows you to send a user message and receive the agent's response:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const response = await client.chat.createChatCompletion({
  chat_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
  content: 'hi how are you doing?',
}) ;
console.log(response.messages) ;
The
content
field is the user message you want to inject, and the endpoint returns the new messages generated by the agent in response. Note that the chat must have a
chat_status
of
ongoing
to receive new messages and generate responses. [(3) ]()
​ To learn more, see the sources I considered: [[1] Create Chat Completion](https://docs.retellai.com/api-references/create-chat-completion) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
s
@AI Evy Is there a way to skip the agents respond and insert a message as the agent? I.e a customer asks a question and I am able to respond as the agent
a
Thanks for the follow-up, @summerpuppet471. I'll get back to you soon.
### Answer Based on the available documentation, there isn't a direct API endpoint to manually insert a message as the agent (bypassing the AI response generation) . The Create Chat Completion endpoint only allows you to send messages with the
role
of
user
via the
content
field, which then triggers the agent to generate a response. [(1) ]() The response object shows messages can have
role
values of
agent
or
user
, but the API input only accepts user content to prompt agent responses. Check out these potentially useful sources for more details: - [Create Chat Completion]() - [Create Chat]() - [Create chat agent]() If you need this functionality (human takeover/agent impersonation) , you may want to reach out to Retell support directly via [Contact Sales]() to inquire if this is on the roadmap or available through another method. Would you like me to try to provide a general answer based on my broader knowledge?
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ To learn more, see the sources I considered: [[1] Create Chat Completion](https://docs.retellai.com/api-references/create-chat-completion) ​