Skip to main content

Send VietJet Email Itinerary

Overview

This flow demonstrates how to send itinerary email using VietJet's API.

Important: This is SEPARATE from the internal email notification system:

  • Internal email: Uses Kafka → Notification Service → Mautic
  • VJ email: Calls VJ API directly → VJ sends email with their template

Both can be used independently or together.

API Endpoint

POST /api/v1/services/booking/v1/gui-email-hang/{ve_id}

Path Parameters

ParameterTypeRequiredDescription
ve_idnumberYesBooking ID

Request Headers

HeaderTypeRequiredDescription
Accept-LanguagestringNoLanguage code: "en" or "vi" (default: "vi")

Request Body

No body required! API automatically:

  • Retrieves email from booking info
  • Gets language from Accept-Language header

Flow Steps

  1. Get Booking Details

    • Retrieves booking information to get VJ key
    • API: GET /api/v1/services/booking/v1/thong-tin-ve
  2. Send Email via VJ API

    • Calls VJ API endpoint
    • URL: /reservations/{key}/emailItinerary
    • Method: POST with query parameters

Example Usage

Using Test Flow

# Send with booking ID
make send-vj-email ID=293 LANG=vi

# Send with PNR
make send-vj-email PNR=A3SFNZ LANG=en

# Default language (vi)
make send-vj-email ID=293

Using in Code

const sendVJEmailItinerary = require('../flows/send-vj-email');

// In your test flow
await sendVJEmailItinerary(CONFIG, STATE, reporter, "en"); // English
await sendVJEmailItinerary(CONFIG, STATE, reporter, "vi"); // Vietnamese

Direct API Call

curl -X POST \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Accept-Language: vi" \
http://localhost:5000/api/v1/services/booking/v1/gui-email-hang/293

VJ API Details

Endpoint

POST {{Endpoint}}/reservations/{key}/emailItinerary

Query Parameters (VJ API)

Response

Success

{
"success": true,
"message": "Email sent successfully",
"data": {
"pnr": "ABC123",
"sent_to": "customer@example.com"
}
}

Error

{
"success": false,
"message": "Error message",
"data": null
}

Notes

  • VJ email uses VJ's own template and branding
  • Separate from internal email notification system
  • Can be triggered manually or programmatically
  • Requires valid VJ API token
  • Does not affect Kafka or notification service

Testing

To test this flow:

cd st-booking-examples
npm run test:vj-email

Or use in your custom flow:

const { setupConfig } = require('./lib/config');
const sendVJEmailItinerary = require('./flows/send-vj-email');

const CONFIG = setupConfig();
const STATE = { BOOKING_ID: 123 };

await sendVJEmailItinerary(CONFIG, STATE);