@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
597 lines • 23 kB
JavaScript
"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.CxFlow = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Flows represents the conversation flows when you build your chatbot agent.
*
* To get more information about Flow, see:
*
* * [API documentation](https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.flows)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/dialogflow/cx/docs)
*
* ## Example Usage
*
* ### Dialogflowcx Flow Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const agent = new gcp.diagflow.CxAgent("agent", {
* displayName: "dialogflowcx-agent",
* location: "global",
* defaultLanguageCode: "en",
* supportedLanguageCodes: [
* "fr",
* "de",
* "es",
* ],
* timeZone: "America/New_York",
* description: "Example description.",
* avatarUri: "https://cloud.google.com/_static/images/cloud/icons/favicons/onecloud/super_cloud.png",
* enableStackdriverLogging: true,
* enableSpellCorrection: true,
* speechToTextSettings: {
* enableSpeechAdaptation: true,
* },
* });
* const basicFlow = new gcp.diagflow.CxFlow("basic_flow", {
* parent: agent.id,
* displayName: "MyFlow",
* description: "Test Flow",
* nluSettings: {
* classificationThreshold: 0.3,
* modelType: "MODEL_TYPE_STANDARD",
* },
* eventHandlers: [
* {
* event: "custom-event",
* triggerFulfillment: {
* returnPartialResponses: false,
* messages: [{
* text: {
* texts: ["I didn't get that. Can you say it again?"],
* },
* }],
* },
* },
* {
* event: "sys.no-match-default",
* triggerFulfillment: {
* returnPartialResponses: false,
* messages: [{
* text: {
* texts: ["Sorry, could you say that again?"],
* },
* }],
* },
* },
* {
* event: "sys.no-input-default",
* triggerFulfillment: {
* returnPartialResponses: false,
* messages: [{
* text: {
* texts: ["One more time?"],
* },
* }],
* },
* },
* ],
* });
* ```
* ### Dialogflowcx Flow Full
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const agent = new gcp.diagflow.CxAgent("agent", {
* displayName: "dialogflowcx-agent",
* location: "global",
* defaultLanguageCode: "en",
* supportedLanguageCodes: [
* "fr",
* "de",
* "es",
* ],
* timeZone: "America/New_York",
* description: "Example description.",
* avatarUri: "https://cloud.google.com/_static/images/cloud/icons/favicons/onecloud/super_cloud.png",
* enableStackdriverLogging: true,
* enableSpellCorrection: true,
* speechToTextSettings: {
* enableSpeechAdaptation: true,
* },
* });
* const bucket = new gcp.storage.Bucket("bucket", {
* name: "dialogflowcx-bucket",
* location: "US",
* uniformBucketLevelAccess: true,
* });
* const myDatastore = new gcp.discoveryengine.DataStore("my_datastore", {
* location: "global",
* dataStoreId: "datastore-flow-full",
* displayName: "datastore-flow-full",
* industryVertical: "GENERIC",
* contentConfig: "NO_CONTENT",
* solutionTypes: ["SOLUTION_TYPE_CHAT"],
* });
* const myWebhook = new gcp.diagflow.CxWebhook("my_webhook", {
* parent: agent.id,
* displayName: "MyWebhook",
* genericWebService: {
* uri: "https://example.com",
* },
* });
* const project = gcp.organizations.getProject({});
* const basicFlow = new gcp.diagflow.CxFlow("basic_flow", {
* parent: agent.id,
* displayName: "MyFlow",
* description: "Test Flow",
* nluSettings: {
* classificationThreshold: 0.3,
* modelType: "MODEL_TYPE_STANDARD",
* },
* eventHandlers: [
* {
* event: "custom-event",
* triggerFulfillment: {
* returnPartialResponses: false,
* messages: [{
* text: {
* texts: ["I didn't get that. Can you say it again?"],
* },
* }],
* },
* },
* {
* event: "sys.no-match-default",
* triggerFulfillment: {
* returnPartialResponses: false,
* messages: [{
* text: {
* texts: ["Sorry, could you say that again?"],
* },
* }],
* },
* },
* {
* event: "sys.no-input-default",
* triggerFulfillment: {
* returnPartialResponses: false,
* messages: [{
* text: {
* texts: ["One more time?"],
* },
* }],
* },
* },
* {
* event: "another-event",
* triggerFulfillment: {
* returnPartialResponses: true,
* messages: [
* {
* channel: "some-channel",
* text: {
* texts: ["Some text"],
* },
* },
* {
* payload: " {\"some-key\": \"some-value\", \"other-key\": [\"other-value\"]}\n",
* },
* {
* conversationSuccess: {
* metadata: " {\"some-metadata-key\": \"some-value\", \"other-metadata-key\": 1234}\n",
* },
* },
* {
* outputAudioText: {
* text: "some output text",
* },
* },
* {
* outputAudioText: {
* ssml: " <speak>Some example <say-as interpret-as=\"characters\">SSML XML</say-as></speak>\n",
* },
* },
* {
* liveAgentHandoff: {
* metadata: " {\"some-metadata-key\": \"some-value\", \"other-metadata-key\": 1234}\n",
* },
* },
* {
* playAudio: {
* audioUri: "http://example.com/some-audio-file.mp3",
* },
* },
* {
* telephonyTransferCall: {
* phoneNumber: "1-234-567-8901",
* },
* },
* ],
* setParameterActions: [
* {
* parameter: "some-param",
* value: "123.45",
* },
* {
* parameter: "another-param",
* value: JSON.stringify("abc"),
* },
* {
* parameter: "other-param",
* value: JSON.stringify(["foo"]),
* },
* ],
* conditionalCases: [{
* cases: JSON.stringify([
* {
* condition: "$sys.func.RAND() < 0.5",
* caseContent: [
* {
* message: {
* text: {
* text: ["First case"],
* },
* },
* },
* {
* additionalCases: {
* cases: [{
* condition: "$sys.func.RAND() < 0.2",
* caseContent: [{
* message: {
* text: {
* text: ["Nested case"],
* },
* },
* }],
* }],
* },
* },
* ],
* },
* {
* caseContent: [{
* message: {
* text: {
* text: ["Final case"],
* },
* },
* }],
* },
* ]),
* }],
* enableGenerativeFallback: true,
* },
* },
* ],
* transitionRoutes: [{
* condition: "true",
* triggerFulfillment: {
* returnPartialResponses: true,
* messages: [
* {
* channel: "some-channel",
* text: {
* texts: ["Some text"],
* },
* },
* {
* payload: " {\"some-key\": \"some-value\", \"other-key\": [\"other-value\"]}\n",
* },
* {
* conversationSuccess: {
* metadata: " {\"some-metadata-key\": \"some-value\", \"other-metadata-key\": 1234}\n",
* },
* },
* {
* outputAudioText: {
* text: "some output text",
* },
* },
* {
* outputAudioText: {
* ssml: " <speak>Some example <say-as interpret-as=\"characters\">SSML XML</say-as></speak>\n",
* },
* },
* {
* liveAgentHandoff: {
* metadata: " {\"some-metadata-key\": \"some-value\", \"other-metadata-key\": 1234}\n",
* },
* },
* {
* playAudio: {
* audioUri: "http://example.com/some-audio-file.mp3",
* },
* },
* {
* telephonyTransferCall: {
* phoneNumber: "1-234-567-8901",
* },
* },
* ],
* setParameterActions: [
* {
* parameter: "some-param",
* value: "123.45",
* },
* {
* parameter: "another-param",
* value: JSON.stringify("abc"),
* },
* {
* parameter: "other-param",
* value: JSON.stringify(["foo"]),
* },
* ],
* conditionalCases: [{
* cases: JSON.stringify([
* {
* condition: "$sys.func.RAND() < 0.5",
* caseContent: [
* {
* message: {
* text: {
* text: ["First case"],
* },
* },
* },
* {
* additionalCases: {
* cases: [{
* condition: "$sys.func.RAND() < 0.2",
* caseContent: [{
* message: {
* text: {
* text: ["Nested case"],
* },
* },
* }],
* }],
* },
* },
* ],
* },
* {
* caseContent: [{
* message: {
* text: {
* text: ["Final case"],
* },
* },
* }],
* },
* ]),
* }],
* },
* targetFlow: agent.startFlow,
* }],
* advancedSettings: {
* audioExportGcsDestination: {
* uri: pulumi.interpolate`${bucket.url}/prefix-`,
* },
* speechSettings: {
* endpointerSensitivity: 30,
* noSpeechTimeout: "3.500s",
* useTimeoutBasedEndpointing: true,
* models: {
* name: "wrench",
* mass: "1.3kg",
* count: "3",
* },
* },
* dtmfSettings: {
* enabled: true,
* maxDigits: 1,
* finishDigit: "#",
* },
* loggingSettings: {
* enableStackdriverLogging: true,
* enableInteractionLogging: true,
* enableConsentBasedRedaction: true,
* },
* },
* knowledgeConnectorSettings: {
* enabled: true,
* triggerFulfillment: {
* messages: [
* {
* channel: "some-channel",
* text: {
* texts: ["information completed, navigating to page 2"],
* },
* },
* {
* payload: " {\"some-key\": \"some-value\", \"other-key\": [\"other-value\"]}\n",
* },
* {
* conversationSuccess: {
* metadata: " {\"some-metadata-key\": \"some-value\", \"other-metadata-key\": 1234}\n",
* },
* },
* {
* outputAudioText: {
* text: "some output text",
* },
* },
* {
* outputAudioText: {
* ssml: " <speak>Some example <say-as interpret-as=\"characters\">SSML XML</say-as></speak>\n",
* },
* },
* {
* liveAgentHandoff: {
* metadata: " {\"some-metadata-key\": \"some-value\", \"other-metadata-key\": 1234}\n",
* },
* },
* {
* playAudio: {
* audioUri: "http://example.com/some-audio-file.mp3",
* },
* },
* {
* telephonyTransferCall: {
* phoneNumber: "1-234-567-8902",
* },
* },
* ],
* webhook: myWebhook.id,
* returnPartialResponses: true,
* tag: "some-tag",
* setParameterActions: [{
* parameter: "some-param",
* value: "123.45",
* }],
* conditionalCases: [{
* cases: JSON.stringify([
* {
* condition: "$sys.func.RAND() < 0.5",
* caseContent: [{
* message: {
* text: {
* text: ["First case"],
* },
* },
* }],
* },
* {
* caseContent: [{
* message: {
* text: {
* text: ["Final case"],
* },
* },
* }],
* },
* ]),
* }],
* advancedSettings: {
* speechSettings: {
* endpointerSensitivity: 30,
* noSpeechTimeout: "3.500s",
* useTimeoutBasedEndpointing: true,
* models: {
* name: "wrench",
* mass: "1.3kg",
* count: "3",
* },
* },
* dtmfSettings: {
* enabled: true,
* maxDigits: 1,
* finishDigit: "#",
* interdigitTimeoutDuration: "3.500s",
* endpointingTimeoutDuration: "3.500s",
* },
* loggingSettings: {
* enableStackdriverLogging: true,
* enableInteractionLogging: true,
* enableConsentBasedRedaction: true,
* },
* },
* enableGenerativeFallback: true,
* },
* dataStoreConnections: [{
* dataStoreType: "UNSTRUCTURED",
* dataStore: pulumi.all([project, agent.location, myDatastore.dataStoreId]).apply(([project, location, dataStoreId]) => `projects/${project.number}/locations/${location}/collections/default_collection/dataStores/${dataStoreId}`),
* documentProcessingMode: "DOCUMENTS",
* }],
* targetFlow: agent.startFlow,
* },
* });
* ```
*
* ## Import
*
* Flow can be imported using any of these accepted formats:
*
* * `{{parent}}/flows/{{name}}`
*
* * `{{parent}}/{{name}}`
*
* When using the `pulumi import` command, Flow can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:diagflow/cxFlow:CxFlow default {{parent}}/flows/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:diagflow/cxFlow:CxFlow default {{parent}}/{{name}}
* ```
*/
class CxFlow extends pulumi.CustomResource {
/**
* Get an existing CxFlow resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new CxFlow(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of CxFlow. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === CxFlow.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["advancedSettings"] = state?.advancedSettings;
resourceInputs["description"] = state?.description;
resourceInputs["displayName"] = state?.displayName;
resourceInputs["eventHandlers"] = state?.eventHandlers;
resourceInputs["isDefaultStartFlow"] = state?.isDefaultStartFlow;
resourceInputs["knowledgeConnectorSettings"] = state?.knowledgeConnectorSettings;
resourceInputs["languageCode"] = state?.languageCode;
resourceInputs["name"] = state?.name;
resourceInputs["nluSettings"] = state?.nluSettings;
resourceInputs["parent"] = state?.parent;
resourceInputs["transitionRouteGroups"] = state?.transitionRouteGroups;
resourceInputs["transitionRoutes"] = state?.transitionRoutes;
}
else {
const args = argsOrState;
if (args?.displayName === undefined && !opts.urn) {
throw new Error("Missing required property 'displayName'");
}
resourceInputs["advancedSettings"] = args?.advancedSettings;
resourceInputs["description"] = args?.description;
resourceInputs["displayName"] = args?.displayName;
resourceInputs["eventHandlers"] = args?.eventHandlers;
resourceInputs["isDefaultStartFlow"] = args?.isDefaultStartFlow;
resourceInputs["knowledgeConnectorSettings"] = args?.knowledgeConnectorSettings;
resourceInputs["languageCode"] = args?.languageCode;
resourceInputs["nluSettings"] = args?.nluSettings;
resourceInputs["parent"] = args?.parent;
resourceInputs["transitionRouteGroups"] = args?.transitionRouteGroups;
resourceInputs["transitionRoutes"] = args?.transitionRoutes;
resourceInputs["name"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(CxFlow.__pulumiType, name, resourceInputs, opts);
}
}
exports.CxFlow = CxFlow;
/** @internal */
CxFlow.__pulumiType = 'gcp:diagflow/cxFlow:CxFlow';
//# sourceMappingURL=cxFlow.js.map