Skip to content

Commit 19c31ba

Browse files
committed
Adding optional id's to ask post
1 parent 1a6eb52 commit 19c31ba

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

packages/workgrid-client/src/client.test.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const server = setupServer(
112112
rest.post(`https://company-code.workgrid.com/v2/ask`, (req, res, ctx) => {
113113
return res(
114114
ctx.json({
115-
text: "Why couldn't the pony speak?",
115+
text: JSON.stringify(req.body),
116116
actions: ['laugh', 'cringe'],
117117
suggestions: ['ask another'],
118118
})
@@ -384,7 +384,33 @@ describe('@workgrid/client', () => {
384384
"suggestions": Array [
385385
"ask another",
386386
],
387-
"text": "Why couldn't the pony speak?",
387+
"text": "{\\"utterance\\":\\"Tell me a joke\\",\\"channel\\":\\"msteams\\",\\"locale\\":\\"en-US\\"}",
388+
}
389+
`)
390+
})
391+
test('ask with ids', async () => {
392+
const result = await client.query([
393+
'ask',
394+
{
395+
spaceId: 'space-id',
396+
utterance: 'Tell me a joke',
397+
channel: 'msteams',
398+
locale: 'en-US',
399+
botId: '123456',
400+
botAliasId: '123456',
401+
},
402+
])
403+
404+
expect(result).toMatchInlineSnapshot(`
405+
Object {
406+
"actions": Array [
407+
"laugh",
408+
"cringe",
409+
],
410+
"suggestions": Array [
411+
"ask another",
412+
],
413+
"text": "{\\"utterance\\":\\"Tell me a joke\\",\\"channel\\":\\"msteams\\",\\"locale\\":\\"en-US\\",\\"botId\\":\\"123456\\",\\"botAliasId\\":\\"123456\\"}",
388414
}
389415
`)
390416
})

packages/workgrid-client/src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,11 +645,11 @@ export interface Queries {
645645

646646
setTypedQueryDefaults('ask', (client) => ({
647647
queryFn: async (context) => {
648-
const { spaceId, utterance, channel, locale } = context.queryKey[1]
648+
const { spaceId, utterance, channel, locale, botId, botAliasId } = context.queryKey[1]
649649

650650
const response = await client.httpClient.post(
651651
'/v2/ask',
652-
{ utterance, channel, locale },
652+
{ utterance, channel, locale, ...(botId ? { botId, botAliasId } : null) },
653653
{
654654
headers: { 'x-workgrid-space': spaceId },
655655
}

0 commit comments

Comments
 (0)