How to use the actions-on-google.RichResponse 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 VoxaAI / voxa / test / dialogflow / DialogflowReply.spec.ts View on Github external
it("should return an empty string for a reply without a simple response", () => {
      const suggestions = new Suggestions("suggestion");
      const richResponse = new RichResponse();
      richResponse.addSuggestion(suggestions);

      reply.payload.google.richResponse = richResponse;
      expect(reply.speech).to.equal("");
    });
  });
github VoxaAI / voxa / test / dialogflow / DialogflowReply.spec.ts View on Github external
it("should return true for a reply with a card", () => {
      const card = new BasicCard({});
      const richResponse = new RichResponse();
      richResponse.add(card);
      reply.payload.google.richResponse = richResponse;
      expect(reply.hasDirectives).to.be.true;
      expect(reply.hasDirective("BasicCard")).to.be.true;
    });
github VoxaAI / voxa / src / platforms / dialogflow / DialogflowReply.ts View on Github external
protected getSimpleResponse(): GoogleActionsV2SimpleResponse {
    const richResponse = this.payload.google.richResponse || new RichResponse();
    this.payload.google.richResponse = richResponse;

    const simpleResponseItem = _.find(
      richResponse.items,
      (item) => !!item.simpleResponse,
    );

    if (simpleResponseItem && simpleResponseItem.simpleResponse) {
      return simpleResponseItem.simpleResponse;
    }

    const simpleResponse = new SimpleResponse("");

    richResponse.add(simpleResponse);

    return simpleResponse;
github VoxaAI / voxa / src / platforms / dialogflow / google / directives.ts View on Github external
public async writeToReply(
    reply: IVoxaReply,
    event: IVoxaEvent,
    transition: ITransition,
  ): Promise<void> {
    const google = (reply as DialogflowReply).payload.google;
    let richResponse: RichResponse = google.richResponse;
    if (!richResponse) {
      richResponse = new RichResponse([]);
    }
    google.richResponse = richResponse;

    let viewPaths = this.viewPaths;
    if (_.isString(viewPaths)) {
      viewPaths = [viewPaths];
    }

    await bluebird.mapSeries(viewPaths, async (view: string) => {
      const statement = await event.renderer.renderPath(view, event);
      if (transition.dialogflowSplitSimpleResponses) {
        richResponse.add(new SimpleResponse(""));
      }
      reply.addStatement(sampleOrItem(statement, event.platform));
    });
  }