fletcherist / yandex-dialogs-sdk

☂️Build your skill for Yandex.Alice with ease. (nodejs/typescript)
MIT License
122 stars 16 forks source link

ctx.userId - inconsistent interaction issue #108

Closed Teoreez closed 4 years ago

Teoreez commented 6 years ago

Full code:

const { Alice, Scene, Reply, Markup } = require('yandex-dialogs-sdk');

const alice = new Alice();

const M = Markup;
const welcomeMatcher = ctx => ctx.data.session.new === true;
alice.command(welcomeMatcher, ctx =>
  Reply.text('Привет! Я загадала число от 1 до 100. Сможешь отгадать его?', {
    buttons: [M.button('Давай попробуем!'), M.button('Не хочу')],
  }),
);

alice.command('Давай попробуем!', ctx => {
    console.log(ctx.message);
    console.log(ctx.userid);
    //const uid = String(ctx.userId);
    //console.log(uid);
    //const uidalt = ctx.get('userId');
    //console.log(uidalt);

});

const server = alice.listen(8080, '/');

Terminal log for normal interaction:

PS H:\Apps\Adventure\Adventure Engine\Adventure-Engine---YandexAlice-MongoDB-JS> node test3.js Давай попробуем! undefined

For: ctx.userid (lowercase)

PS H:\Apps\Adventure\Adventure Engine\Adventure-Engine---YandexAlice-MongoDB-JS> node test3.js Давай попробуем! undefined

For:

const uidalt = ctx.get('userId');
console.log(uidalt);

PS H:\Apps\Adventure\Adventure Engine\Adventure-Engine---YandexAlice-MongoDB-JS> node test3.js Давай попробуем! undefined

And Finaly For:

const uid = String(ctx.userId);
console.log(uid);

PS H:\Apps\Adventure\Adventure Engine\Adventure-Engine---YandexAlice-MongoDB-JS> node test3.js 11dff563-fa0c-5017-99d7-cdd70c90119b

Tadam...

fletcherist commented 4 years ago

no longer reproducable