Skip to content

Commit d8bf15c

Browse files
Merge pull request #411 from Workgrid/ask-update
2 parents 1a6eb52 + e89c44b commit d8bf15c

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

packages/workgrid-client-react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@workgrid/client-react",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"main": "dist/client-react.js",
55
"types": "dist/client-react.d.ts",
66
"files": [
@@ -21,7 +21,7 @@
2121
},
2222
"dependencies": {
2323
"@testing-library/react-hooks": "^5.1.0",
24-
"@workgrid/client": "^0.0.7",
24+
"@workgrid/client": "^0.0.8",
2525
"react-query": "^3.12.2"
2626
},
2727
"devDependencies": {

packages/workgrid-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@workgrid/client",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"main": "dist/client.js",
55
"types": "dist/client.d.ts",
66
"files": [

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)