Connection-Time Configuration
Oftentimes clients need to provide configuration data to the server when starting the bot. This can include things like preferred language, user preferences, initial messages, or any other data that the server needs to know about the client. This must occur before the bot is started and therefore is not part of the RTVI standard, but rather a custom implementation. That said, thePipecatClient
makes it easy to send this data as part of the startBot()
and startBotAndConnect()
methods, by passing an API endpoint object with the requestData
property. Your server endpoint can then handle this data as needed. In the example below, we demonstrate sending an initial prompt and preferred language to the server when connecting.
Sending Custom Messages to the Server
Once connected, you can send custom messages to the server using thesendClientMessage
method. This is useful for triggering specific actions or sending data that the server needs to process.
Requesting Information from the Server
You can also request information from the server using thesendClientRequest
method. This is useful for querying the server for specific data or triggering and action and getting a success/failure response.
Handling Custom Messages from the Server
You can handle custom messages sent from the server using theonServerMessage
callback. This allows you to process messages that the server sends back to the client, such as notifications or updates.