Inject Agent Message

Send a message to immediately trigger an Agent statement.

Some common ways to use the injectAgentMessageare:

  • Informing the user that the agent is working on a lengthy function call ("Hold on while I look that up for you")
  • Prompting the user to continue if the user hasn't spoken for a while ("Are you still on the line?")

What is the InjectAgentMessage

TheInjectAgentMessage message is a JSON command you can send to immediately trigger an agent statement. If the injection request arrives while the user is speaking, or while the server is in the middle of sending audio for an agent response, then the request will be ignored and the server will reply with anInjectionRefused. The client should only try to inject agent messages during silent portions of the conversation.

Sending InjectAgentMessage

To send the InjectAgentMessage message, you need to send the following JSON message to the server:

{
  "type": "InjectAgentMessage",
  "message": "" // The statement the agent should say
}

InjectAgentMessage Confirmation

{
    "type": "AgentAudioDone"
}

InjectAgentMessage Rejection

{
    "type": "InjectionRefused"
}

Conclusion

The InjectAgentMessage message provides a way to immediately trigger an agent response during a conversation. However, it must be carefully timed, as the request will be ignored if the user is speaking or if the agent is already responding. To ensure successful injection, the client should only attempt it during silent moments, avoiding interruptions and potential InjectionRefused errors.