Skip to content

Commit fb82031

Browse files
committed
add visitor timezone to React Native voice token
1 parent 499f78f commit fb82031

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎src/api.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,20 @@ export class ChattyClient {
226226
* credentials never leave Chatty's backend. Connect the returned values with
227227
* the official `@livekit/react-native` client in the host application.
228228
*/
229-
async createVoiceToken(sessionId: string, participantName = "Visitor"): Promise<ChattyVoiceToken> {
229+
async createVoiceToken(
230+
sessionId: string,
231+
participantName = "Visitor",
232+
visitorTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone,
233+
): Promise<ChattyVoiceToken> {
230234
const res = await fetch(buildUrl(this.baseUrl, "/api/widget/voice/token", {}), {
231235
method: "POST",
232236
headers: { "Content-Type": "application/json" },
233-
body: JSON.stringify({ bot_id: this.botId, session_id: sessionId, participant_name: participantName }),
237+
body: JSON.stringify({
238+
bot_id: this.botId,
239+
session_id: sessionId,
240+
participant_name: participantName,
241+
visitor_timezone: visitorTimezone,
242+
}),
234243
});
235244
if (res.status === 429) throw new ChattyRateLimitError();
236245
if (res.status === 403) throw new ChattyDomainNotAllowedError();

0 commit comments

Comments
 (0)