UNPKG

@pulumi/gcp

Version:

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

785 lines (784 loc) • 34.7 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * 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}} * ``` */ export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: CxFlowState, opts?: pulumi.CustomResourceOptions): CxFlow; /** * 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: any): obj is CxFlow; /** * Hierarchical advanced settings for this flow. The settings exposed at the lower level overrides the settings exposed at the higher level. * Hierarchy: Agent->Flow->Page->Fulfillment/Parameter. * Structure is documented below. */ readonly advancedSettings: pulumi.Output<outputs.diagflow.CxFlowAdvancedSettings | undefined>; /** * The description of the flow. The maximum length is 500 characters. If exceeded, the request is rejected. */ readonly description: pulumi.Output<string | undefined>; /** * The human-readable name of the flow. */ readonly displayName: pulumi.Output<string>; /** * A flow's event handlers serve two purposes: * They are responsible for handling events (e.g. no match, webhook errors) in the flow. * They are inherited by every page's [event handlers][Page.event_handlers], which can be used to handle common events regardless of the current page. Event handlers defined in the page have higher priority than those defined in the flow. * Unlike transitionRoutes, these handlers are evaluated on a first-match basis. The first one that matches the event get executed, with the rest being ignored. * Structure is documented below. */ readonly eventHandlers: pulumi.Output<outputs.diagflow.CxFlowEventHandler[]>; /** * Marks this as the [Default Start Flow](https://cloud.google.com/dialogflow/cx/docs/concept/flow#start) for an agent. When you create an agent, the Default Start Flow is created automatically. * The Default Start Flow cannot be deleted; deleting the `gcp.diagflow.CxFlow` resource does nothing to the underlying GCP resources. * * > Avoid having multiple `gcp.diagflow.CxFlow` resources linked to the same agent with `isDefaultStartFlow = true` because they will compete to control a single Default Start Flow resource in GCP. */ readonly isDefaultStartFlow: pulumi.Output<boolean | undefined>; /** * Knowledge connector configuration. * Structure is documented below. */ readonly knowledgeConnectorSettings: pulumi.Output<outputs.diagflow.CxFlowKnowledgeConnectorSettings | undefined>; /** * The language of the following fields in flow: * Flow.event_handlers.trigger_fulfillment.messages * Flow.event_handlers.trigger_fulfillment.conditional_cases * Flow.transition_routes.trigger_fulfillment.messages * Flow.transition_routes.trigger_fulfillment.conditional_cases * If not specified, the agent's default language is used. Many languages are supported. Note: languages must be enabled in the agent before they can be used. */ readonly languageCode: pulumi.Output<string | undefined>; /** * The unique identifier of the flow. * Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>. */ readonly name: pulumi.Output<string>; /** * NLU related settings of the flow. * Structure is documented below. */ readonly nluSettings: pulumi.Output<outputs.diagflow.CxFlowNluSettings | undefined>; /** * The agent to create a flow for. * Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>. */ readonly parent: pulumi.Output<string | undefined>; /** * A flow's transition route group serve two purposes: * They are responsible for matching the user's first utterances in the flow. * They are inherited by every page's [transition route groups][Page.transition_route_groups]. Transition route groups defined in the page have higher priority than those defined in the flow. * Format:projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/transitionRouteGroups/<TransitionRouteGroup ID>. */ readonly transitionRouteGroups: pulumi.Output<string[] | undefined>; /** * A flow's transition routes serve two purposes: * They are responsible for matching the user's first utterances in the flow. * They are inherited by every page's [transition routes][Page.transition_routes] and can support use cases such as the user saying "help" or "can I talk to a human?", which can be handled in a common way regardless of the current page. Transition routes defined in the page have higher priority than those defined in the flow. * TransitionRoutes are evalauted in the following order: * TransitionRoutes with intent specified. * TransitionRoutes with only condition specified. * TransitionRoutes with intent specified are inherited by pages in the flow. * Structure is documented below. */ readonly transitionRoutes: pulumi.Output<outputs.diagflow.CxFlowTransitionRoute[] | undefined>; /** * Create a CxFlow resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: CxFlowArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering CxFlow resources. */ export interface CxFlowState { /** * Hierarchical advanced settings for this flow. The settings exposed at the lower level overrides the settings exposed at the higher level. * Hierarchy: Agent->Flow->Page->Fulfillment/Parameter. * Structure is documented below. */ advancedSettings?: pulumi.Input<inputs.diagflow.CxFlowAdvancedSettings>; /** * The description of the flow. The maximum length is 500 characters. If exceeded, the request is rejected. */ description?: pulumi.Input<string>; /** * The human-readable name of the flow. */ displayName?: pulumi.Input<string>; /** * A flow's event handlers serve two purposes: * They are responsible for handling events (e.g. no match, webhook errors) in the flow. * They are inherited by every page's [event handlers][Page.event_handlers], which can be used to handle common events regardless of the current page. Event handlers defined in the page have higher priority than those defined in the flow. * Unlike transitionRoutes, these handlers are evaluated on a first-match basis. The first one that matches the event get executed, with the rest being ignored. * Structure is documented below. */ eventHandlers?: pulumi.Input<pulumi.Input<inputs.diagflow.CxFlowEventHandler>[]>; /** * Marks this as the [Default Start Flow](https://cloud.google.com/dialogflow/cx/docs/concept/flow#start) for an agent. When you create an agent, the Default Start Flow is created automatically. * The Default Start Flow cannot be deleted; deleting the `gcp.diagflow.CxFlow` resource does nothing to the underlying GCP resources. * * > Avoid having multiple `gcp.diagflow.CxFlow` resources linked to the same agent with `isDefaultStartFlow = true` because they will compete to control a single Default Start Flow resource in GCP. */ isDefaultStartFlow?: pulumi.Input<boolean>; /** * Knowledge connector configuration. * Structure is documented below. */ knowledgeConnectorSettings?: pulumi.Input<inputs.diagflow.CxFlowKnowledgeConnectorSettings>; /** * The language of the following fields in flow: * Flow.event_handlers.trigger_fulfillment.messages * Flow.event_handlers.trigger_fulfillment.conditional_cases * Flow.transition_routes.trigger_fulfillment.messages * Flow.transition_routes.trigger_fulfillment.conditional_cases * If not specified, the agent's default language is used. Many languages are supported. Note: languages must be enabled in the agent before they can be used. */ languageCode?: pulumi.Input<string>; /** * The unique identifier of the flow. * Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>. */ name?: pulumi.Input<string>; /** * NLU related settings of the flow. * Structure is documented below. */ nluSettings?: pulumi.Input<inputs.diagflow.CxFlowNluSettings>; /** * The agent to create a flow for. * Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>. */ parent?: pulumi.Input<string>; /** * A flow's transition route group serve two purposes: * They are responsible for matching the user's first utterances in the flow. * They are inherited by every page's [transition route groups][Page.transition_route_groups]. Transition route groups defined in the page have higher priority than those defined in the flow. * Format:projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/transitionRouteGroups/<TransitionRouteGroup ID>. */ transitionRouteGroups?: pulumi.Input<pulumi.Input<string>[]>; /** * A flow's transition routes serve two purposes: * They are responsible for matching the user's first utterances in the flow. * They are inherited by every page's [transition routes][Page.transition_routes] and can support use cases such as the user saying "help" or "can I talk to a human?", which can be handled in a common way regardless of the current page. Transition routes defined in the page have higher priority than those defined in the flow. * TransitionRoutes are evalauted in the following order: * TransitionRoutes with intent specified. * TransitionRoutes with only condition specified. * TransitionRoutes with intent specified are inherited by pages in the flow. * Structure is documented below. */ transitionRoutes?: pulumi.Input<pulumi.Input<inputs.diagflow.CxFlowTransitionRoute>[]>; } /** * The set of arguments for constructing a CxFlow resource. */ export interface CxFlowArgs { /** * Hierarchical advanced settings for this flow. The settings exposed at the lower level overrides the settings exposed at the higher level. * Hierarchy: Agent->Flow->Page->Fulfillment/Parameter. * Structure is documented below. */ advancedSettings?: pulumi.Input<inputs.diagflow.CxFlowAdvancedSettings>; /** * The description of the flow. The maximum length is 500 characters. If exceeded, the request is rejected. */ description?: pulumi.Input<string>; /** * The human-readable name of the flow. */ displayName: pulumi.Input<string>; /** * A flow's event handlers serve two purposes: * They are responsible for handling events (e.g. no match, webhook errors) in the flow. * They are inherited by every page's [event handlers][Page.event_handlers], which can be used to handle common events regardless of the current page. Event handlers defined in the page have higher priority than those defined in the flow. * Unlike transitionRoutes, these handlers are evaluated on a first-match basis. The first one that matches the event get executed, with the rest being ignored. * Structure is documented below. */ eventHandlers?: pulumi.Input<pulumi.Input<inputs.diagflow.CxFlowEventHandler>[]>; /** * Marks this as the [Default Start Flow](https://cloud.google.com/dialogflow/cx/docs/concept/flow#start) for an agent. When you create an agent, the Default Start Flow is created automatically. * The Default Start Flow cannot be deleted; deleting the `gcp.diagflow.CxFlow` resource does nothing to the underlying GCP resources. * * > Avoid having multiple `gcp.diagflow.CxFlow` resources linked to the same agent with `isDefaultStartFlow = true` because they will compete to control a single Default Start Flow resource in GCP. */ isDefaultStartFlow?: pulumi.Input<boolean>; /** * Knowledge connector configuration. * Structure is documented below. */ knowledgeConnectorSettings?: pulumi.Input<inputs.diagflow.CxFlowKnowledgeConnectorSettings>; /** * The language of the following fields in flow: * Flow.event_handlers.trigger_fulfillment.messages * Flow.event_handlers.trigger_fulfillment.conditional_cases * Flow.transition_routes.trigger_fulfillment.messages * Flow.transition_routes.trigger_fulfillment.conditional_cases * If not specified, the agent's default language is used. Many languages are supported. Note: languages must be enabled in the agent before they can be used. */ languageCode?: pulumi.Input<string>; /** * NLU related settings of the flow. * Structure is documented below. */ nluSettings?: pulumi.Input<inputs.diagflow.CxFlowNluSettings>; /** * The agent to create a flow for. * Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>. */ parent?: pulumi.Input<string>; /** * A flow's transition route group serve two purposes: * They are responsible for matching the user's first utterances in the flow. * They are inherited by every page's [transition route groups][Page.transition_route_groups]. Transition route groups defined in the page have higher priority than those defined in the flow. * Format:projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/transitionRouteGroups/<TransitionRouteGroup ID>. */ transitionRouteGroups?: pulumi.Input<pulumi.Input<string>[]>; /** * A flow's transition routes serve two purposes: * They are responsible for matching the user's first utterances in the flow. * They are inherited by every page's [transition routes][Page.transition_routes] and can support use cases such as the user saying "help" or "can I talk to a human?", which can be handled in a common way regardless of the current page. Transition routes defined in the page have higher priority than those defined in the flow. * TransitionRoutes are evalauted in the following order: * TransitionRoutes with intent specified. * TransitionRoutes with only condition specified. * TransitionRoutes with intent specified are inherited by pages in the flow. * Structure is documented below. */ transitionRoutes?: pulumi.Input<pulumi.Input<inputs.diagflow.CxFlowTransitionRoute>[]>; }