Verwenden von API-Aufrufantworten in benutzerdefinierten Aktionen custom-action-enhancements

Auf dieser Seite Erfassen Sie die JSON-Antwort, die von einer benutzerdefinierten Aktion zurückgegeben wird, und verwenden Sie ihre Felder, um Journey-Entscheidungen zu treffen, Nachrichten zu personalisieren und Fehler zu behandeln.

Anforderungen an die Antwort-Payload custom-action-enhancements-notes

  • Die vollständige Antwort muss ein JSON-Objekt sein. Ein bloßes -Array, da die Antwort nicht unterstützt wird.

  • Arrays können in einem Objekt enthalten sein. Scalar-Arrays werden unterstützt, heterogene Arrays dagegen nicht.

Unterstützt:

{
  "body": ["val1", "val2"],
  "points": 1290
}

Nicht unterstützt (bloßes Array):

["val1", "val2"]

Nicht unterstützt (heterogenes Array):

{
  "values": [20, "aafw", false]
}

Konfigurieren der benutzerdefinierten Aktion config-response

Um die Antwort einer benutzerdefinierten Aktion zu erfassen, definieren Sie ein Beispiel für die Payload, die Ihr Endpunkt zurückgibt.

  1. Erstellen oder öffnen Sie eine benutzerdefinierte Aktion. Siehe Konfigurieren einer benutzerdefinierten ​.

  2. Klicken Sie in das Feld Antwort (Erfolgsantwort).

    {width="80%"}

  3. Fügen Sie ein Beispiel für die erfolgreiche Antwort ein, die Ihr Endpunkt zurückgibt. Überprüfen Sie, ob die Feldtypen des Beispiels mit der tatsächlichen Antwort übereinstimmen. In diesem Beispiel sendet der lokale Endpunkt die Anzahl der Treuepunkte und den Status eines Profils.

    code language-json
    {
      "customerID": "xY12hye",
      "status": "gold",
      "points": 1290
    }
    

    {width="80%"}

    Im Beispiel werden die Felder definiert, die Journey Optimizer jedes Mal abruft, wenn die Aktion aufgerufen wird.

  4. (Optional) Um eine Fehler-Payload zu erfassen, wählen Sie Fehlerantwort-Payload definieren und geben Sie ein Beispiel, das der Payload entspricht, die Ihr Endpunkt zurückgibt, wenn der Aufruf fehlschlägt. Beispiel:

    code language-json
    {
      "message": "customer not found"
    }
    

    Nach der Konfiguration sind die Payload-Felder für Fehler unter dem Knoten errorResponse verfügbar. Die Form der Probe sollte der tatsächlichen Fehlerantwort entsprechen.

  5. Fügen Sie alle erforderlichen Anfrageparameter hinzu. In diesem Beispiel ist customerID ein Abfrageparameter.

    {width="80%"}

  6. Klicken Sie auf Speichern.

Antwort in einer Journey verwenden response-in-journey

Fügen Sie die benutzerdefinierte Aktion einer Journey hinzu. Anschließend können Sie die Antwortfelder in Bedingungen, nachfolgenden Aktionen und der Nachrichtenpersonalisierung verwenden.

Sie können beispielsweise eine Bedingung hinzufügen, um die Anzahl der Treuepunkte zu überprüfen. Wenn die Person das Restaurant betritt, sendet Ihr lokaler Endpunkt einen Aufruf mit den Treueinformationen des Profils. Sie können eine Push-Benachrichtigung versenden, wenn das Profil zu den Goldkundinnen und -kunden gehört. Wenn beim Aufruf ein Fehler erkannt wird, senden Sie eine benutzerdefinierte Aktion, um Ihre Systemadministratorin oder Ihren Systemadministrator zu benachrichtigen.

  1. Fügen Sie Ihr Ereignis und die zuvor erstellte benutzerdefinierte Treue-Aktion hinzu.

  2. Ordnen Sie in der benutzerdefinierten Aktion Treue die erforderlichen Eingabeparameter, wie z. B. den Abfrageparameter Kunden-ID , der Profil-ID zu. Wählen Sie Alternativen Pfad hinzufügen, falls eine Zeitüberschreitung oder ein Fehler auftritt aus, um diese Ergebnisse separat zu behandeln.

  3. Fügen Sie im Erfolgspfad eine Bedingung hinzu und verwenden Sie die Felder für die Aktionsantwort. Im erweiterten Editor sind die Antwortfelder unter dem Knoten Kontext verfügbar.

  4. Fügen Sie eine Push-Benachrichtigung oder eine andere Aktion hinzu und personalisieren Sie Ihre Nachricht mithilfe der Antwortfelder. In diesem Beispiel nutzt der Inhalt die Anzahl der Treuepunkte und den Kundenstatus. Die Antwortfelder finden Sie unter Kontextuelle Attribute > Journey Orchestration > Actions.

    note
    NOTE
    Jedes Profil, das in die benutzerdefinierte Aktion eintritt, führt einen Trigger aus, auch wenn der Endpunkt für jedes Profil dieselbe Antwort zurückgibt.
  5. Fügen Sie im Pfad der maximalen Wartezeit und des Fehlers eine Bedingung hinzu und verwenden Sie das integrierte Feld jo_status_code, um eine Verzweigung nach dem Aufrufergebnis herzustellen. In diesem Beispiel prüft die Bedingung auf den Fehlertyp http_400. Siehe Fehlerstatus.

    code language-none
    @action{ActionLoyalty.jo_status_code} == "http_400"
    

    Wenn Sie eine Payload mit Fehlern konfiguriert haben, können Sie auch eine Verzweigung in einem der zugehörigen Felder ausführen. Im obigen Beispiel:

    code language-none
    @action{ActionLoyalty.errorResponse.message} == "customer not found"
    

  6. Fügen Sie eine benutzerdefinierte Aktion hinzu, die Ihre Organisation benachrichtigt.

Testmodusprotokolle test-mode-logs

Verwenden Sie den Testmodus, um die von der Aktion zurückgegebene Payload im Abschnitt actionsHistory der Protokolle zu überprüfen. Bei fehlgeschlagenen Aufrufen enthalten die Protokolle die Fehler-Payload, sofern eine konfiguriert ist. Dies ist für das Debugging nützlich.

Fehlerstatus error-status

Das Feld jo_status_code ist auch dann verfügbar, wenn keine Antwort-Payload definiert ist. Mögliche Werte:

Wert
Bedeutung
http_<code>
Vom API-Aufruf zurückgegebener HTTP-Status-Code, z. B. http_200 oder http_400
timedout
Die Zeit für den Aufruf wurde überschritten
capped
Der Aufruf wurde durch Begrenzung blockiert
internalError
Ein interner Fehler ist aufgetreten

Ein Aktionsaufruf wird als fehlerhaft betrachtet, wenn der zurückgegebene HTTP-Code größer als 2xx ist oder wenn ein anderer Fehler auftritt. In diesem Fall folgt die Journey der konfigurierten Zeitüberschreitungs- oder Fehlerverzweigung.

Nur neu erstellte benutzerdefinierte Aktionen enthalten standardmäßig das Feld JO_STATUS_CODE . Um sie mit einer vorhandenen benutzerdefinierten Aktion zu verwenden, aktualisieren und speichern Sie die Aktion. Sie können beispielsweise die Beschreibung aktualisieren.

Wenn keine Fehlerantwort-Payload konfiguriert ist, ist der errorResponse-Knoten nicht verfügbar.

Syntax von Ausdrücken exp-syntax

Referenzieren Sie ein Antwortfeld mit:

@action{<action name>.<field path>}

Beispiel:

@action{ActionLoyalty.status}

So geben Sie einen Standardwert an:

@action{<action name>.<field path>, defaultValue: <expression>}

Beispiel:

@action{ActionLoyalty.points, defaultValue: 0}
@action{ActionLoyalty.points, defaultValue: @event{myEvent.newPoints}}

Für Sammlungen verwenden Sie currentActionField , um auf das aktuelle Element zu verweisen:

count(
  @action{MyAction.MyCollection.all(
    currentActionField.description == "abc"
  )}
)

Siehe Feldverweise und Funktionen zur Sammlungsverwaltung.

Nachrichten im nativen Kanal personalisieren response-in-channels

Verwenden Sie benutzerdefinierte Aktionsantwortfelder in der unterstützten nativen Kanalpersonalisierung (E-Mail, Push, mobile Nachrichten). Informationen zu Arrays und verschachtelten Daten finden Sie unter Iterieren über kontextuelle Daten mit Handlebars.

Fehlerbehebung troubleshooting

Symptom
nachprüfen
Antwortfelder sind nicht verfügbar
Vergewissern Sie sich dass das ResponseJSON ist und die Antwortstruktur und die Feldtypen des Endpunkts widerspiegelt.
Die Antwort kann nicht verwendet werden, da es sich um ein Array handelt.
Gibt stattdessen ein -Objekt zurück und platziert das -Array innerhalb eines -Felds.
Einige Array-Werte sind nicht verfügbar
Vergewissern Sie sich, dass das Array nicht heterogen ist.
jo_status_code fehlt in einer vorhandenen Aktion
Aktualisieren und speichern Sie die Aktion. Das Feld ist standardmäßig nur in neu erstellten Aktionen enthalten.
errorResponse ist nicht verfügbar
Konfigurieren und speichern Sie eine Payload für die Fehlerantwort.
Der Aufruf folgt der Zeitüberschreitungs- oder Fehlerverzweigung
Überprüfen Sie die jo_status_code und, falls konfiguriert, die Fehler-Payload in den Testmodus-Protokollen.

Zusätzliche Ressourcen

AI Knowledge Reference

This section contains structured knowledge intended to support interpretation, retrieval, and question answering related to this topic.

For complete understanding, this information should be combined with the documentation on this page. Neither source is intended to stand alone; the page describes the feature, while this section provides additional context that helps disambiguate terminology, intent, applicability, and constraints.

  • TL;DR: This page explains how to capture the JSON response returned by a custom action and use its fields to guide journey decisions, personalize messages, and handle errors.

Intents:

  • Define a sample of the successful response your endpoint returns in the Response (success response) field of a custom action.
  • Capture a failure payload by selecting Define a failure response payload and providing an example that matches the payload your endpoint returns when the call fails.
  • Use custom action response fields in journey conditions, subsequent actions, and message personalization.
  • Branch on the call outcome in the timeout and error path of a journey with the built-in jo_status_code field or, if a failure payload is configured, with one of its fields.
  • Inspect the payload returned by the action in the actionsHistory section of the test mode logs.
  • Reference a response field with the @action{<action name>.<field path>} syntax, optionally with a default value.

Glossary:

  • Response (success response) field: The custom action field where you paste an example of the successful response your endpoint returns. The sample defines the fields that Journey Optimizer retrieves each time the action is called. (product-specific)
  • Failure response payload: An optional example of the payload your endpoint returns when the call fails, captured by selecting Define a failure response payload. When configured, its fields are available under the errorResponse node. (product-specific)
  • jo_status_code: A built-in field used to branch on the call outcome. It is available even when no response payload is defined. Possible values include http_<code> (HTTP status code returned by the API call, such as http_200 or http_400), timedout (the call timed out), capped (the call was blocked by capping) and internalError (an internal error occurred). (product-specific)
  • currentActionField: In a response field expression on a collection, refers to the current item. (product-specific)
  • actionsHistory: The section of the test mode logs where you inspect the payload returned by the action. For failed calls, the logs include the failure payload if one is configured. (product-specific)

Guardrails:

  • The complete response must be a JSON object. A bare array as the response is not supported.
  • Arrays can be included inside an object. Scalar arrays are supported; heterogeneous arrays are not supported.
  • Only newly created custom actions include the jo_status_code field by default. To use it with an existing custom action, update and save the action, for example by updating its description.
  • If no failure response payload is configured, the errorResponse node is not available.

Terminology:

  • Canonical name: Adobe Journey Optimizer — Acronym: AJO — variants: Journey Optimizer
  • Canonical name: failure response payload — variants: failure payload
  • Canonical name: timeout and error path — variants: timeout or error branch, alternative path in case of a timeout or error

FAQ:

  • Can the response of a custom action be an array? No. The complete response must be a JSON object; return an object instead, placing the array inside a field.
  • Where are the response fields available in a journey? In the advanced editor of a condition, the response fields are available under the Context node. For message personalization, they are available under Contextual attributes > Journey Orchestration > Actions.
  • When is an action call considered in error? When the returned HTTP code is greater than 2xx or when another error occurs. In that case, the journey follows the configured timeout or error branch.
  • Does each profile trigger a call? Yes. Each profile entering the custom action triggers a call, even if the endpoint returns the same response for every profile.
  • Can custom action response fields be used in native-channel messages? Yes, in supported native-channel personalization (email, push, mobile messages).
  • How do I provide a default value for a response field? Use @action{<action name>.<field path>, defaultValue: <expression>}, for example @action{ActionLoyalty.points, defaultValue: 0}.

Troubleshooting:

  • Response fields are unavailable: Confirm that the Response sample is valid JSON and reflects the endpoint’s response structure and field types.
  • The call follows the timeout or error branch: Inspect jo_status_code and, if configured, the failure payload in the test mode logs.

Examples:

  • Loyalty use case: when the person enters the restaurant, your local endpoint sends a call with the profile’s loyalty information. A condition checks the number of loyalty points, you can send a push if the profile is a gold customer, and if an error is detected in the call, a custom action notifies your system administrator.
  • Success response sample: {"customerID": "xY12hye", "status": "gold", "points": 1290}, where customerID is a query parameter.
  • Failure response sample: {"message": "customer not found"}, used in the condition @action{ActionLoyalty.errorResponse.message} == "customer not found".
  • Condition on the call outcome: @action{ActionLoyalty.jo_status_code} == "http_400".
  • Supported response: {"body": ["val1", "val2"], "points": 1290}. Not supported: the bare array ["val1", "val2"] and the heterogeneous array {"values": [20, "aafw", false]}.
  • Collection expression: count(@action{MyAction.MyCollection.all(currentActionField.description == "abc")}).

Best practices:

  • Verify that the field types of the success response sample match the actual response.
  • The shape of the failure response sample should match the real failure response.

Related pages:

Personas:

  • developer: Can reference a custom action response field with @action{<action name>.<field path>}, for example @action{ActionLoyalty.status}. Can provide a default value with @action{<action name>.<field path>, defaultValue: <expression>}. Can use currentActionField to refer to the current item of a collection. Where: “Expression syntax”.
  • admin: Can paste an example of the successful response the endpoint returns in the Response (success response) field of a custom action. Can select Define a failure response payload and provide an example of the payload the endpoint returns when the call fails. The page states that the failure payload fields are available under the errorResponse node when configured. Where: “Configure the custom action”.

Onboarding:

  • Level: Experienced
  • First minimal step: Create or open a custom action, then paste an example of the successful response your endpoint returns in the Response (success response) field.
  • Previous: To create or open a custom action: Configure a custom action
recommendation-more-help
journey-optimizer-help