The Interactions Protocol allows users to interact dynamically with the Replica live during an active conversation via broadcasting interactions. The following interactions are available:

  • Echo interactions
  • Response interactions
  • Interrupt interactions
  • Override conversation context interactions
  • Sensitivity interactions

In addition to interactions, users are able to listen to incoming events from the Replica. Specifically you can listen for:

  • Utterance events
  • Tool call events

Setting up Interactions Protocol

The interactions protocol uses the data-channel on WebRTC (Daily) in order to transmit and receive events between your server and CVI.

In order to use the interactions protocol, you must have a client that can connect to the data channel. We use Daily as our WebRTC provider, which makes it easy to setup a client.

The Daily app-message event is used to send and receive events and interactions between your server and CVI.

Here’s an example of using DailyJS to create a call client in Javascript:

<html>
  <script crossorigin src="https://unpkg.com/@daily-co/daily-js"></script>
  <body>
    <!-- Add input field and send button -->
    <input type="text" id="messageInput" placeholder="Enter your message">
    <button onclick="sendAppMessage()">Send Message</button>

    <script>
      call = window.Daily.createFrame();
      call.on('app-message', (event) => {
        console.log('app-message', event);
      });
      
      call.join({ url: 'YOUR_CONVERSATION_URL' });

      function sendAppMessage() {
        const messageInput = document.getElementById('messageInput');
        const message = messageInput.value;
        if (message) {
          const interaction = {
            "message_type": "conversation",
            "event_type": "conversation.echo",
            "conversation_id": "YOUR_CONVERSATION_ID",
            "properties": {
              "text": `${message}`
            }
          }
          const hi = call.sendAppMessage({message: interaction }, '*');
          console.log('Sending message: ', hi);
          console.log('Sent message: ', interaction);
          messageInput.value = '';
        }
      }
    </script>
  </body>
</html>

Here’s an example of using Daily Python to create a call client in Javascript:

call_client = None

class RoomHandler(EventHandler):
    def __init__(self):
        super().__init__()
    
    def on_app_message(self, message, sender: str) -> None:
        print(f"Incoming app message from {sender}: {message}")

def join_room(url):
    global call_client
    try:
        Daily.init()
        output_handler = RoomHandler()
        call_client = CallClient(event_handler=output_handler)
        call_client.join(url)
    except Exception as e:
        print(f"Error joining room: {e}")
        raise

def send_message(message):
    global call_client
    call_client.send_app_message(message)

Available Interactions

Available Events