UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

471 lines • 18.3 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** 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 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"], * }, * }, * }], * }, * ]), * }], * }, * }, * ], * 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, * }, * }, * }); * ``` * * ## 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, Object.assign(Object.assign({}, 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 ? state.advancedSettings : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["displayName"] = state ? state.displayName : undefined; resourceInputs["eventHandlers"] = state ? state.eventHandlers : undefined; resourceInputs["isDefaultStartFlow"] = state ? state.isDefaultStartFlow : undefined; resourceInputs["languageCode"] = state ? state.languageCode : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["nluSettings"] = state ? state.nluSettings : undefined; resourceInputs["parent"] = state ? state.parent : undefined; resourceInputs["transitionRouteGroups"] = state ? state.transitionRouteGroups : undefined; resourceInputs["transitionRoutes"] = state ? state.transitionRoutes : undefined; } else { const args = argsOrState; if ((!args || args.displayName === undefined) && !opts.urn) { throw new Error("Missing required property 'displayName'"); } resourceInputs["advancedSettings"] = args ? args.advancedSettings : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["displayName"] = args ? args.displayName : undefined; resourceInputs["eventHandlers"] = args ? args.eventHandlers : undefined; resourceInputs["isDefaultStartFlow"] = args ? args.isDefaultStartFlow : undefined; resourceInputs["languageCode"] = args ? args.languageCode : undefined; resourceInputs["nluSettings"] = args ? args.nluSettings : undefined; resourceInputs["parent"] = args ? args.parent : undefined; resourceInputs["transitionRouteGroups"] = args ? args.transitionRouteGroups : undefined; resourceInputs["transitionRoutes"] = args ? args.transitionRoutes : undefined; 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