{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.LexRuntime.Types.DialogAction
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.LexRuntime.Types.DialogAction where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LexRuntime.Types.DialogActionType
import Amazonka.LexRuntime.Types.FulfillmentState
import Amazonka.LexRuntime.Types.MessageFormatType
import qualified Amazonka.Prelude as Prelude

-- | Describes the next action that the bot should take in its interaction
-- with the user and provides information about the context in which the
-- action takes place. Use the @DialogAction@ data type to set the
-- interaction to a specific state, or to return the interaction to a
-- previous state.
--
-- /See:/ 'newDialogAction' smart constructor.
data DialogAction = DialogAction'
  { -- | Map of the slots that have been gathered and their values.
    DialogAction -> Maybe (Sensitive (HashMap Text Text))
slots :: Prelude.Maybe (Core.Sensitive (Prelude.HashMap Prelude.Text Prelude.Text)),
    -- | The name of the intent.
    DialogAction -> Maybe Text
intentName :: Prelude.Maybe Prelude.Text,
    -- | The fulfillment state of the intent. The possible values are:
    --
    -- -   @Failed@ - The Lambda function associated with the intent failed to
    --     fulfill the intent.
    --
    -- -   @Fulfilled@ - The intent has fulfilled by the Lambda function
    --     associated with the intent.
    --
    -- -   @ReadyForFulfillment@ - All of the information necessary for the
    --     intent is present and the intent ready to be fulfilled by the client
    --     application.
    DialogAction -> Maybe FulfillmentState
fulfillmentState :: Prelude.Maybe FulfillmentState,
    -- | -   @PlainText@ - The message contains plain UTF-8 text.
    --
    -- -   @CustomPayload@ - The message is a custom format for the client.
    --
    -- -   @SSML@ - The message contains text formatted for voice output.
    --
    -- -   @Composite@ - The message contains an escaped JSON object containing
    --     one or more messages. For more information, see
    --     <https://docs.aws.amazon.com/lex/latest/dg/howitworks-manage-prompts.html Message Groups>.
    DialogAction -> Maybe MessageFormatType
messageFormat :: Prelude.Maybe MessageFormatType,
    -- | The message that should be shown to the user. If you don\'t specify a
    -- message, Amazon Lex will use the message configured for the intent.
    DialogAction -> Maybe (Sensitive Text)
message :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The name of the slot that should be elicited from the user.
    DialogAction -> Maybe Text
slotToElicit :: Prelude.Maybe Prelude.Text,
    -- | The next action that the bot should take in its interaction with the
    -- user. The possible values are:
    --
    -- -   @ConfirmIntent@ - The next action is asking the user if the intent
    --     is complete and ready to be fulfilled. This is a yes\/no question
    --     such as \"Place the order?\"
    --
    -- -   @Close@ - Indicates that the there will not be a response from the
    --     user. For example, the statement \"Your order has been placed\" does
    --     not require a response.
    --
    -- -   @Delegate@ - The next action is determined by Amazon Lex.
    --
    -- -   @ElicitIntent@ - The next action is to determine the intent that the
    --     user wants to fulfill.
    --
    -- -   @ElicitSlot@ - The next action is to elicit a slot value from the
    --     user.
    DialogAction -> DialogActionType
type' :: DialogActionType
  }
  deriving (DialogAction -> DialogAction -> Bool
(DialogAction -> DialogAction -> Bool)
-> (DialogAction -> DialogAction -> Bool) -> Eq DialogAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DialogAction -> DialogAction -> Bool
$c/= :: DialogAction -> DialogAction -> Bool
== :: DialogAction -> DialogAction -> Bool
$c== :: DialogAction -> DialogAction -> Bool
Prelude.Eq, Int -> DialogAction -> ShowS
[DialogAction] -> ShowS
DialogAction -> String
(Int -> DialogAction -> ShowS)
-> (DialogAction -> String)
-> ([DialogAction] -> ShowS)
-> Show DialogAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DialogAction] -> ShowS
$cshowList :: [DialogAction] -> ShowS
show :: DialogAction -> String
$cshow :: DialogAction -> String
showsPrec :: Int -> DialogAction -> ShowS
$cshowsPrec :: Int -> DialogAction -> ShowS
Prelude.Show, (forall x. DialogAction -> Rep DialogAction x)
-> (forall x. Rep DialogAction x -> DialogAction)
-> Generic DialogAction
forall x. Rep DialogAction x -> DialogAction
forall x. DialogAction -> Rep DialogAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DialogAction x -> DialogAction
$cfrom :: forall x. DialogAction -> Rep DialogAction x
Prelude.Generic)

-- |
-- Create a value of 'DialogAction' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'slots', 'dialogAction_slots' - Map of the slots that have been gathered and their values.
--
-- 'intentName', 'dialogAction_intentName' - The name of the intent.
--
-- 'fulfillmentState', 'dialogAction_fulfillmentState' - The fulfillment state of the intent. The possible values are:
--
-- -   @Failed@ - The Lambda function associated with the intent failed to
--     fulfill the intent.
--
-- -   @Fulfilled@ - The intent has fulfilled by the Lambda function
--     associated with the intent.
--
-- -   @ReadyForFulfillment@ - All of the information necessary for the
--     intent is present and the intent ready to be fulfilled by the client
--     application.
--
-- 'messageFormat', 'dialogAction_messageFormat' - -   @PlainText@ - The message contains plain UTF-8 text.
--
-- -   @CustomPayload@ - The message is a custom format for the client.
--
-- -   @SSML@ - The message contains text formatted for voice output.
--
-- -   @Composite@ - The message contains an escaped JSON object containing
--     one or more messages. For more information, see
--     <https://docs.aws.amazon.com/lex/latest/dg/howitworks-manage-prompts.html Message Groups>.
--
-- 'message', 'dialogAction_message' - The message that should be shown to the user. If you don\'t specify a
-- message, Amazon Lex will use the message configured for the intent.
--
-- 'slotToElicit', 'dialogAction_slotToElicit' - The name of the slot that should be elicited from the user.
--
-- 'type'', 'dialogAction_type' - The next action that the bot should take in its interaction with the
-- user. The possible values are:
--
-- -   @ConfirmIntent@ - The next action is asking the user if the intent
--     is complete and ready to be fulfilled. This is a yes\/no question
--     such as \"Place the order?\"
--
-- -   @Close@ - Indicates that the there will not be a response from the
--     user. For example, the statement \"Your order has been placed\" does
--     not require a response.
--
-- -   @Delegate@ - The next action is determined by Amazon Lex.
--
-- -   @ElicitIntent@ - The next action is to determine the intent that the
--     user wants to fulfill.
--
-- -   @ElicitSlot@ - The next action is to elicit a slot value from the
--     user.
newDialogAction ::
  -- | 'type''
  DialogActionType ->
  DialogAction
newDialogAction :: DialogActionType -> DialogAction
newDialogAction DialogActionType
pType_ =
  DialogAction' :: Maybe (Sensitive (HashMap Text Text))
-> Maybe Text
-> Maybe FulfillmentState
-> Maybe MessageFormatType
-> Maybe (Sensitive Text)
-> Maybe Text
-> DialogActionType
-> DialogAction
DialogAction'
    { $sel:slots:DialogAction' :: Maybe (Sensitive (HashMap Text Text))
slots = Maybe (Sensitive (HashMap Text Text))
forall a. Maybe a
Prelude.Nothing,
      $sel:intentName:DialogAction' :: Maybe Text
intentName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fulfillmentState:DialogAction' :: Maybe FulfillmentState
fulfillmentState = Maybe FulfillmentState
forall a. Maybe a
Prelude.Nothing,
      $sel:messageFormat:DialogAction' :: Maybe MessageFormatType
messageFormat = Maybe MessageFormatType
forall a. Maybe a
Prelude.Nothing,
      $sel:message:DialogAction' :: Maybe (Sensitive Text)
message = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:slotToElicit:DialogAction' :: Maybe Text
slotToElicit = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':DialogAction' :: DialogActionType
type' = DialogActionType
pType_
    }

-- | Map of the slots that have been gathered and their values.
dialogAction_slots :: Lens.Lens' DialogAction (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
dialogAction_slots :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DialogAction -> f DialogAction
dialogAction_slots = (DialogAction -> Maybe (Sensitive (HashMap Text Text)))
-> (DialogAction
    -> Maybe (Sensitive (HashMap Text Text)) -> DialogAction)
-> Lens
     DialogAction
     DialogAction
     (Maybe (Sensitive (HashMap Text Text)))
     (Maybe (Sensitive (HashMap Text Text)))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DialogAction' {Maybe (Sensitive (HashMap Text Text))
slots :: Maybe (Sensitive (HashMap Text Text))
$sel:slots:DialogAction' :: DialogAction -> Maybe (Sensitive (HashMap Text Text))
slots} -> Maybe (Sensitive (HashMap Text Text))
slots) (\s :: DialogAction
s@DialogAction' {} Maybe (Sensitive (HashMap Text Text))
a -> DialogAction
s {$sel:slots:DialogAction' :: Maybe (Sensitive (HashMap Text Text))
slots = Maybe (Sensitive (HashMap Text Text))
a} :: DialogAction) ((Maybe (Sensitive (HashMap Text Text))
  -> f (Maybe (Sensitive (HashMap Text Text))))
 -> DialogAction -> f DialogAction)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (Sensitive (HashMap Text Text))
    -> f (Maybe (Sensitive (HashMap Text Text))))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DialogAction
-> f DialogAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (Sensitive (HashMap Text Text))
  (Sensitive (HashMap Text Text))
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (Sensitive (HashMap Text Text)))
     (Maybe (Sensitive (HashMap Text Text)))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping (AnIso
  (Sensitive (HashMap Text Text))
  (Sensitive (HashMap Text Text))
  (HashMap Text Text)
  (HashMap Text Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive AnIso
  (Sensitive (HashMap Text Text))
  (Sensitive (HashMap Text Text))
  (HashMap Text Text)
  (HashMap Text Text)
-> (Exchange
      (HashMap Text Text)
      (HashMap Text Text)
      (HashMap Text Text)
      (Identity (HashMap Text Text))
    -> Exchange
         (HashMap Text Text)
         (HashMap Text Text)
         (HashMap Text Text)
         (Identity (HashMap Text Text)))
-> AnIso
     (Sensitive (HashMap Text Text))
     (Sensitive (HashMap Text Text))
     (HashMap Text Text)
     (HashMap Text Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Exchange
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (Identity (HashMap Text Text))
-> Exchange
     (HashMap Text Text)
     (HashMap Text Text)
     (HashMap Text Text)
     (Identity (HashMap Text Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced)

-- | The name of the intent.
dialogAction_intentName :: Lens.Lens' DialogAction (Prelude.Maybe Prelude.Text)
dialogAction_intentName :: (Maybe Text -> f (Maybe Text)) -> DialogAction -> f DialogAction
dialogAction_intentName = (DialogAction -> Maybe Text)
-> (DialogAction -> Maybe Text -> DialogAction)
-> Lens DialogAction DialogAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DialogAction' {Maybe Text
intentName :: Maybe Text
$sel:intentName:DialogAction' :: DialogAction -> Maybe Text
intentName} -> Maybe Text
intentName) (\s :: DialogAction
s@DialogAction' {} Maybe Text
a -> DialogAction
s {$sel:intentName:DialogAction' :: Maybe Text
intentName = Maybe Text
a} :: DialogAction)

-- | The fulfillment state of the intent. The possible values are:
--
-- -   @Failed@ - The Lambda function associated with the intent failed to
--     fulfill the intent.
--
-- -   @Fulfilled@ - The intent has fulfilled by the Lambda function
--     associated with the intent.
--
-- -   @ReadyForFulfillment@ - All of the information necessary for the
--     intent is present and the intent ready to be fulfilled by the client
--     application.
dialogAction_fulfillmentState :: Lens.Lens' DialogAction (Prelude.Maybe FulfillmentState)
dialogAction_fulfillmentState :: (Maybe FulfillmentState -> f (Maybe FulfillmentState))
-> DialogAction -> f DialogAction
dialogAction_fulfillmentState = (DialogAction -> Maybe FulfillmentState)
-> (DialogAction -> Maybe FulfillmentState -> DialogAction)
-> Lens
     DialogAction
     DialogAction
     (Maybe FulfillmentState)
     (Maybe FulfillmentState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DialogAction' {Maybe FulfillmentState
fulfillmentState :: Maybe FulfillmentState
$sel:fulfillmentState:DialogAction' :: DialogAction -> Maybe FulfillmentState
fulfillmentState} -> Maybe FulfillmentState
fulfillmentState) (\s :: DialogAction
s@DialogAction' {} Maybe FulfillmentState
a -> DialogAction
s {$sel:fulfillmentState:DialogAction' :: Maybe FulfillmentState
fulfillmentState = Maybe FulfillmentState
a} :: DialogAction)

-- | -   @PlainText@ - The message contains plain UTF-8 text.
--
-- -   @CustomPayload@ - The message is a custom format for the client.
--
-- -   @SSML@ - The message contains text formatted for voice output.
--
-- -   @Composite@ - The message contains an escaped JSON object containing
--     one or more messages. For more information, see
--     <https://docs.aws.amazon.com/lex/latest/dg/howitworks-manage-prompts.html Message Groups>.
dialogAction_messageFormat :: Lens.Lens' DialogAction (Prelude.Maybe MessageFormatType)
dialogAction_messageFormat :: (Maybe MessageFormatType -> f (Maybe MessageFormatType))
-> DialogAction -> f DialogAction
dialogAction_messageFormat = (DialogAction -> Maybe MessageFormatType)
-> (DialogAction -> Maybe MessageFormatType -> DialogAction)
-> Lens
     DialogAction
     DialogAction
     (Maybe MessageFormatType)
     (Maybe MessageFormatType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DialogAction' {Maybe MessageFormatType
messageFormat :: Maybe MessageFormatType
$sel:messageFormat:DialogAction' :: DialogAction -> Maybe MessageFormatType
messageFormat} -> Maybe MessageFormatType
messageFormat) (\s :: DialogAction
s@DialogAction' {} Maybe MessageFormatType
a -> DialogAction
s {$sel:messageFormat:DialogAction' :: Maybe MessageFormatType
messageFormat = Maybe MessageFormatType
a} :: DialogAction)

-- | The message that should be shown to the user. If you don\'t specify a
-- message, Amazon Lex will use the message configured for the intent.
dialogAction_message :: Lens.Lens' DialogAction (Prelude.Maybe Prelude.Text)
dialogAction_message :: (Maybe Text -> f (Maybe Text)) -> DialogAction -> f DialogAction
dialogAction_message = (DialogAction -> Maybe (Sensitive Text))
-> (DialogAction -> Maybe (Sensitive Text) -> DialogAction)
-> Lens
     DialogAction
     DialogAction
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DialogAction' {Maybe (Sensitive Text)
message :: Maybe (Sensitive Text)
$sel:message:DialogAction' :: DialogAction -> Maybe (Sensitive Text)
message} -> Maybe (Sensitive Text)
message) (\s :: DialogAction
s@DialogAction' {} Maybe (Sensitive Text)
a -> DialogAction
s {$sel:message:DialogAction' :: Maybe (Sensitive Text)
message = Maybe (Sensitive Text)
a} :: DialogAction) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> DialogAction -> f DialogAction)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> DialogAction
-> f DialogAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The name of the slot that should be elicited from the user.
dialogAction_slotToElicit :: Lens.Lens' DialogAction (Prelude.Maybe Prelude.Text)
dialogAction_slotToElicit :: (Maybe Text -> f (Maybe Text)) -> DialogAction -> f DialogAction
dialogAction_slotToElicit = (DialogAction -> Maybe Text)
-> (DialogAction -> Maybe Text -> DialogAction)
-> Lens DialogAction DialogAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DialogAction' {Maybe Text
slotToElicit :: Maybe Text
$sel:slotToElicit:DialogAction' :: DialogAction -> Maybe Text
slotToElicit} -> Maybe Text
slotToElicit) (\s :: DialogAction
s@DialogAction' {} Maybe Text
a -> DialogAction
s {$sel:slotToElicit:DialogAction' :: Maybe Text
slotToElicit = Maybe Text
a} :: DialogAction)

-- | The next action that the bot should take in its interaction with the
-- user. The possible values are:
--
-- -   @ConfirmIntent@ - The next action is asking the user if the intent
--     is complete and ready to be fulfilled. This is a yes\/no question
--     such as \"Place the order?\"
--
-- -   @Close@ - Indicates that the there will not be a response from the
--     user. For example, the statement \"Your order has been placed\" does
--     not require a response.
--
-- -   @Delegate@ - The next action is determined by Amazon Lex.
--
-- -   @ElicitIntent@ - The next action is to determine the intent that the
--     user wants to fulfill.
--
-- -   @ElicitSlot@ - The next action is to elicit a slot value from the
--     user.
dialogAction_type :: Lens.Lens' DialogAction DialogActionType
dialogAction_type :: (DialogActionType -> f DialogActionType)
-> DialogAction -> f DialogAction
dialogAction_type = (DialogAction -> DialogActionType)
-> (DialogAction -> DialogActionType -> DialogAction)
-> Lens DialogAction DialogAction DialogActionType DialogActionType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DialogAction' {DialogActionType
type' :: DialogActionType
$sel:type':DialogAction' :: DialogAction -> DialogActionType
type'} -> DialogActionType
type') (\s :: DialogAction
s@DialogAction' {} DialogActionType
a -> DialogAction
s {$sel:type':DialogAction' :: DialogActionType
type' = DialogActionType
a} :: DialogAction)

instance Core.FromJSON DialogAction where
  parseJSON :: Value -> Parser DialogAction
parseJSON =
    String
-> (Object -> Parser DialogAction) -> Value -> Parser DialogAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DialogAction"
      ( \Object
x ->
          Maybe (Sensitive (HashMap Text Text))
-> Maybe Text
-> Maybe FulfillmentState
-> Maybe MessageFormatType
-> Maybe (Sensitive Text)
-> Maybe Text
-> DialogActionType
-> DialogAction
DialogAction'
            (Maybe (Sensitive (HashMap Text Text))
 -> Maybe Text
 -> Maybe FulfillmentState
 -> Maybe MessageFormatType
 -> Maybe (Sensitive Text)
 -> Maybe Text
 -> DialogActionType
 -> DialogAction)
-> Parser (Maybe (Sensitive (HashMap Text Text)))
-> Parser
     (Maybe Text
      -> Maybe FulfillmentState
      -> Maybe MessageFormatType
      -> Maybe (Sensitive Text)
      -> Maybe Text
      -> DialogActionType
      -> DialogAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Parser (Maybe (Maybe (Sensitive (HashMap Text Text))))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"slots" Parser (Maybe (Maybe (Sensitive (HashMap Text Text))))
-> Maybe (Sensitive (HashMap Text Text))
-> Parser (Maybe (Sensitive (HashMap Text Text)))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (Sensitive (HashMap Text Text))
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> Maybe FulfillmentState
   -> Maybe MessageFormatType
   -> Maybe (Sensitive Text)
   -> Maybe Text
   -> DialogActionType
   -> DialogAction)
-> Parser (Maybe Text)
-> Parser
     (Maybe FulfillmentState
      -> Maybe MessageFormatType
      -> Maybe (Sensitive Text)
      -> Maybe Text
      -> DialogActionType
      -> DialogAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"intentName")
            Parser
  (Maybe FulfillmentState
   -> Maybe MessageFormatType
   -> Maybe (Sensitive Text)
   -> Maybe Text
   -> DialogActionType
   -> DialogAction)
-> Parser (Maybe FulfillmentState)
-> Parser
     (Maybe MessageFormatType
      -> Maybe (Sensitive Text)
      -> Maybe Text
      -> DialogActionType
      -> DialogAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FulfillmentState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"fulfillmentState")
            Parser
  (Maybe MessageFormatType
   -> Maybe (Sensitive Text)
   -> Maybe Text
   -> DialogActionType
   -> DialogAction)
-> Parser (Maybe MessageFormatType)
-> Parser
     (Maybe (Sensitive Text)
      -> Maybe Text -> DialogActionType -> DialogAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MessageFormatType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"messageFormat")
            Parser
  (Maybe (Sensitive Text)
   -> Maybe Text -> DialogActionType -> DialogAction)
-> Parser (Maybe (Sensitive Text))
-> Parser (Maybe Text -> DialogActionType -> DialogAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"message")
            Parser (Maybe Text -> DialogActionType -> DialogAction)
-> Parser (Maybe Text) -> Parser (DialogActionType -> DialogAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"slotToElicit")
            Parser (DialogActionType -> DialogAction)
-> Parser DialogActionType -> Parser DialogAction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser DialogActionType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"type")
      )

instance Prelude.Hashable DialogAction

instance Prelude.NFData DialogAction

instance Core.ToJSON DialogAction where
  toJSON :: DialogAction -> Value
toJSON DialogAction' {Maybe Text
Maybe (Sensitive Text)
Maybe (Sensitive (HashMap Text Text))
Maybe FulfillmentState
Maybe MessageFormatType
DialogActionType
type' :: DialogActionType
slotToElicit :: Maybe Text
message :: Maybe (Sensitive Text)
messageFormat :: Maybe MessageFormatType
fulfillmentState :: Maybe FulfillmentState
intentName :: Maybe Text
slots :: Maybe (Sensitive (HashMap Text Text))
$sel:type':DialogAction' :: DialogAction -> DialogActionType
$sel:slotToElicit:DialogAction' :: DialogAction -> Maybe Text
$sel:message:DialogAction' :: DialogAction -> Maybe (Sensitive Text)
$sel:messageFormat:DialogAction' :: DialogAction -> Maybe MessageFormatType
$sel:fulfillmentState:DialogAction' :: DialogAction -> Maybe FulfillmentState
$sel:intentName:DialogAction' :: DialogAction -> Maybe Text
$sel:slots:DialogAction' :: DialogAction -> Maybe (Sensitive (HashMap Text Text))
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"slots" Text -> Sensitive (HashMap Text Text) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive (HashMap Text Text) -> Pair)
-> Maybe (Sensitive (HashMap Text Text)) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive (HashMap Text Text))
slots,
            (Text
"intentName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
intentName,
            (Text
"fulfillmentState" Text -> FulfillmentState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (FulfillmentState -> Pair) -> Maybe FulfillmentState -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FulfillmentState
fulfillmentState,
            (Text
"messageFormat" Text -> MessageFormatType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (MessageFormatType -> Pair)
-> Maybe MessageFormatType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MessageFormatType
messageFormat,
            (Text
"message" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
message,
            (Text
"slotToElicit" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
slotToElicit,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> DialogActionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DialogActionType
type')
          ]
      )