Simple Counter using Dialogflow Conv.Data or Conv.User.Storage
up vote
1
down vote
favorite
I am looking to create a super simple counter in a conversation in a firebase function using actions for google.
the documentation recommends:
app.intent('Default Welcome Intent', conv =>
conv.data.someProperty = 'someValue'
)
However, typescript does not recognise any kind of dot notation after conv.data as a value, and does not allow the code to deploy.
however, as far as I can determine, using
app.intent('Default Welcome Intent', conv =>
conv.data["someProperty"] = 1;
)
Does, but doesn't seem to permit counting the int...
I have tried:
conv.data['currentIndex'] = parseInt(conv.data['currentIndex']) + 1;
conv.data['currentIndex'] = parseInt(conv.data['currentIndex'])++;
conv.data['currentIndex'] += 1;
I feel I am missing something super fundamental here.
Thanks
node.js typescript google-cloud-functions dialogflow actions-on-google
add a comment |
up vote
1
down vote
favorite
I am looking to create a super simple counter in a conversation in a firebase function using actions for google.
the documentation recommends:
app.intent('Default Welcome Intent', conv =>
conv.data.someProperty = 'someValue'
)
However, typescript does not recognise any kind of dot notation after conv.data as a value, and does not allow the code to deploy.
however, as far as I can determine, using
app.intent('Default Welcome Intent', conv =>
conv.data["someProperty"] = 1;
)
Does, but doesn't seem to permit counting the int...
I have tried:
conv.data['currentIndex'] = parseInt(conv.data['currentIndex']) + 1;
conv.data['currentIndex'] = parseInt(conv.data['currentIndex'])++;
conv.data['currentIndex'] += 1;
I feel I am missing something super fundamental here.
Thanks
node.js typescript google-cloud-functions dialogflow actions-on-google
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am looking to create a super simple counter in a conversation in a firebase function using actions for google.
the documentation recommends:
app.intent('Default Welcome Intent', conv =>
conv.data.someProperty = 'someValue'
)
However, typescript does not recognise any kind of dot notation after conv.data as a value, and does not allow the code to deploy.
however, as far as I can determine, using
app.intent('Default Welcome Intent', conv =>
conv.data["someProperty"] = 1;
)
Does, but doesn't seem to permit counting the int...
I have tried:
conv.data['currentIndex'] = parseInt(conv.data['currentIndex']) + 1;
conv.data['currentIndex'] = parseInt(conv.data['currentIndex'])++;
conv.data['currentIndex'] += 1;
I feel I am missing something super fundamental here.
Thanks
node.js typescript google-cloud-functions dialogflow actions-on-google
I am looking to create a super simple counter in a conversation in a firebase function using actions for google.
the documentation recommends:
app.intent('Default Welcome Intent', conv =>
conv.data.someProperty = 'someValue'
)
However, typescript does not recognise any kind of dot notation after conv.data as a value, and does not allow the code to deploy.
however, as far as I can determine, using
app.intent('Default Welcome Intent', conv =>
conv.data["someProperty"] = 1;
)
Does, but doesn't seem to permit counting the int...
I have tried:
conv.data['currentIndex'] = parseInt(conv.data['currentIndex']) + 1;
conv.data['currentIndex'] = parseInt(conv.data['currentIndex'])++;
conv.data['currentIndex'] += 1;
I feel I am missing something super fundamental here.
Thanks
node.js typescript google-cloud-functions dialogflow actions-on-google
node.js typescript google-cloud-functions dialogflow actions-on-google
asked Nov 9 at 18:48
Tristram Tolliday
376
376
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
I think you need to explicitly specify types of variables you want to use.
Try defining interfaces like:
//use this in conv.data
interface ConvData
counter?: number
// use in conv.user.storage
interface UserStorage
location?: string
name?: string
and initializing the app as:
const app = dialogflow<ConvData, UserStorage>( debug: true )
and then using
app.intent('Default Welcome Intent', conv =>
conv.data.counter = 1
)
Reference: Actions on Google TS sample
https://github.com/actions-on-google/actions-on-google-nodejs/blob/935d0f9adfe78a4f9eb83ab4bb0fb9f6a7db2001/samples/ts/app/name-psychic/functions/src/index.tsx
Hope that helps!
1
Perfect, that's worked a treat. thanks @sai-raj
– Tristram Tolliday
Nov 10 at 22:02
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
I think you need to explicitly specify types of variables you want to use.
Try defining interfaces like:
//use this in conv.data
interface ConvData
counter?: number
// use in conv.user.storage
interface UserStorage
location?: string
name?: string
and initializing the app as:
const app = dialogflow<ConvData, UserStorage>( debug: true )
and then using
app.intent('Default Welcome Intent', conv =>
conv.data.counter = 1
)
Reference: Actions on Google TS sample
https://github.com/actions-on-google/actions-on-google-nodejs/blob/935d0f9adfe78a4f9eb83ab4bb0fb9f6a7db2001/samples/ts/app/name-psychic/functions/src/index.tsx
Hope that helps!
1
Perfect, that's worked a treat. thanks @sai-raj
– Tristram Tolliday
Nov 10 at 22:02
add a comment |
up vote
2
down vote
accepted
I think you need to explicitly specify types of variables you want to use.
Try defining interfaces like:
//use this in conv.data
interface ConvData
counter?: number
// use in conv.user.storage
interface UserStorage
location?: string
name?: string
and initializing the app as:
const app = dialogflow<ConvData, UserStorage>( debug: true )
and then using
app.intent('Default Welcome Intent', conv =>
conv.data.counter = 1
)
Reference: Actions on Google TS sample
https://github.com/actions-on-google/actions-on-google-nodejs/blob/935d0f9adfe78a4f9eb83ab4bb0fb9f6a7db2001/samples/ts/app/name-psychic/functions/src/index.tsx
Hope that helps!
1
Perfect, that's worked a treat. thanks @sai-raj
– Tristram Tolliday
Nov 10 at 22:02
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
I think you need to explicitly specify types of variables you want to use.
Try defining interfaces like:
//use this in conv.data
interface ConvData
counter?: number
// use in conv.user.storage
interface UserStorage
location?: string
name?: string
and initializing the app as:
const app = dialogflow<ConvData, UserStorage>( debug: true )
and then using
app.intent('Default Welcome Intent', conv =>
conv.data.counter = 1
)
Reference: Actions on Google TS sample
https://github.com/actions-on-google/actions-on-google-nodejs/blob/935d0f9adfe78a4f9eb83ab4bb0fb9f6a7db2001/samples/ts/app/name-psychic/functions/src/index.tsx
Hope that helps!
I think you need to explicitly specify types of variables you want to use.
Try defining interfaces like:
//use this in conv.data
interface ConvData
counter?: number
// use in conv.user.storage
interface UserStorage
location?: string
name?: string
and initializing the app as:
const app = dialogflow<ConvData, UserStorage>( debug: true )
and then using
app.intent('Default Welcome Intent', conv =>
conv.data.counter = 1
)
Reference: Actions on Google TS sample
https://github.com/actions-on-google/actions-on-google-nodejs/blob/935d0f9adfe78a4f9eb83ab4bb0fb9f6a7db2001/samples/ts/app/name-psychic/functions/src/index.tsx
Hope that helps!
edited Nov 10 at 2:02
answered Nov 10 at 1:56
sai.raj
517
517
1
Perfect, that's worked a treat. thanks @sai-raj
– Tristram Tolliday
Nov 10 at 22:02
add a comment |
1
Perfect, that's worked a treat. thanks @sai-raj
– Tristram Tolliday
Nov 10 at 22:02
1
1
Perfect, that's worked a treat. thanks @sai-raj
– Tristram Tolliday
Nov 10 at 22:02
Perfect, that's worked a treat. thanks @sai-raj
– Tristram Tolliday
Nov 10 at 22:02
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231680%2fsimple-counter-using-dialogflow-conv-data-or-conv-user-storage%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown