I’m using Whatsapp Connector so that whenever a user sends a message during the call, I want that message the user sent via whatsapp chat to be sent to the agent using sendText ( Sending text | LiveKit Documentation ).
This sending of text is triggered by a webhook. So when I receive a specific webhook, I’m triggering to send the text to the agent. Here is how the backend server is sending the text to the agent.
def create_room_admin_token(room: str) -> str:
token = api.AccessToken(os.getenv('LIVEKIT_API_KEY'),
os.getenv('LIVEKIT_API_SECRET')) \
.with_identity("Token-Generator") \
.with_name("Kamal") \
.with_grants(api.VideoGrants(
room_join=True,
room_admin=True,
can_publish=True,
can_subscribe=True,
room=room)).to_jwt()
return token
async def publish_whatsapp_message_to_room(
content: PublishWhatsappMessage
):
room = rtc.Room()
try:
# Connect backend participant to the room
await room.connect(
os.getenv("LIVEKIT_URL"),
create_room_admin_token(content.room_name),
)
# Publish text message to lk.chat
info = await room.local_participant.send_text(
content.message_text,
topic="lk.chat",
)
return f"Sent text with stream ID: {info.stream_id}"
finally:
await room.disconnect()
In my testing, I have seen that the text is actually being sent because I see this in my logs:
“Sent text with stream ID: cee1a037-5e51-4552-961e-ed5563a8add8”
But I have noticed that the text is being sent from the agent to the human. I have noticed this when testing this in agent console. In my case i sent a tracking number. If you check the image below, it shows that the image is sent from the agent to the human.
Because of this, the agent doesn’t know that it has received text and can’t use the text for further action.
I would like to know, how can I specify that when sending text, send the text from the human participant to the agent participant.
