-
Notifications
You must be signed in to change notification settings - Fork 3
/
v1.js
33 lines (30 loc) · 938 Bytes
/
v1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* @typedef {import('../../client.js').ChatBotKitClient} ChatBotKitClient
*/
/**
* @typedef {{
* durationInSeconds?: number
* }} BotSessionCreateRequest
*
* @typedef {{
* conversationId: string,
* token: string,
* expiresAt: number
* }} BotSessionCreateResponse
*
* @param {ChatBotKitClient} client
* @param {string} botId
* @param {BotSessionCreateRequest} request
* @returns {Promise<BotSessionCreateResponse>}
*/
export async function createBotSession(client, botId, request) {
const url = `/api/v1/bot/${botId}/session/create`
/** @type {import('../../types/api/v1.js').operations['createBotSession']['responses']['200']['content']['application/json']} */
const response = await client.clientFetch(url, {
/** @type {import('../../types/api/v1.js').operations['createBotSession']['requestBody']['content']['application/json']} */
record: {
...request,
},
})
return response
}