How to use the actions-on-google.SignIn function in actions-on-google

To help you get started, we’ve selected a few actions-on-google examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nielsmaerten / nightscout-assistant / functions / index.js View on Github external
app.intent("Glucose Status", async conv => {
  // Start a timer
  const tStart = performance.now();

  // Get translation function for this user's locale
  await initializedLocale;
  const t = i18next.getFixedT(conv.user.locale);

  // Does the user have an active account?
  if (conv.user.profile.token === undefined) {
    // No? Ask them to sign in first
    conv.ask(new SignIn(t("signIn.request")));
    return;
  }

  // Get user profile from db
  const userEmail = conv.user.email;
  const userProfile = await nightscout.getUserProfile(userEmail);

  // Get current glucose from Nightscout
  const nightscoutStatus = await nightscout.getNightscoutStatus(
    userProfile,
    userEmail,
    t
  );

  // Conversations using the latest API will always hear the disclaimer
  const headerVersion = +conv.headers["x-nsstatus-api-version"];
github VoxaAI / voxa / test / dialogflow / DialogflowReply.spec.ts View on Github external
it("should return true for a reply with an AccountLinkingCard", () => {
      const signIn = new SignIn();
      reply.payload.google.systemIntent = {
        data: signIn.inputValueData,
        intent: signIn.intent,
      };
      expect(reply.hasDirectives).to.be.true;
      expect(reply.hasDirective("BasicCard")).to.be.false;
      expect(reply.hasDirective(signIn.intent as string)).to.be.true;
    });
  });
github PinkyJie / google-actions-github-bot / functions / src / actions.ts View on Github external
app.intent(INTENTS.NEW_SURFACE_RESULT, (conv, params, newSurfaceResult) => {
    const status = (newSurfaceResult as IntentResult).status;
    console.log('new surface result: ', status);
    if (status === 'OK') {
        return conv.ask(new SignIn());
    } else {
        return conv.ask(PROMPTS.SIGN_IN_TRANSFER_NO);
    }
});
github actions-on-google / dialogflow-iosched-nodejs / functions / prompts / schedule / utils.js View on Github external
session.isStarred = scheduleSession.isStarred;
          }
        }
        return callback(sessions);
      }).catch((error) => {
        console.error(`Error getting session data for user schedule ${error}`);
        parse(conv, prompts['show-schedule']().error);
      });
    }).catch((error) => {
      console.error(`Error getting user schedule: ${error}`);
      parse(conv, prompts['show-schedule']().error);
    });
  } else {
    conv.user.storage.uid = undefined;
    if (conv.screen) {
      conv.ask(new SignIn());
    } else {
      return parse(conv, prompts['sign-in-user-on-speaker']);
    }
  }
};
github PinkyJie / google-actions-github-bot / functions / src / actions.ts View on Github external
function handleSignIn(conv: CONV_TYPE) {
    const hasScreen = conv.surface.capabilities.has(SIGN_SURFACE_CAPABILITY);
    if (hasScreen) {
        return conv.ask(new SignIn());
    }
    const screenAvailable = conv.available.surfaces.capabilities.has(
        SIGN_SURFACE_CAPABILITY
    );
    if (screenAvailable) {
        return conv.ask(
            new NewSurface({
                context: PROMPTS.SIGN_IN_ASK_FOR_TRANSFER,
                notification: 'Link Github to star a repository',
                capabilities: SIGN_SURFACE_CAPABILITY,
            })
        );
    } else {
        conv.contexts.set(
            CONTEXTS.FETCH_TRENDING_FOLLOWUP,
            DEFAULT_CONTEXT_LIFE_SPAN