# The external service will trigger the webhook

---

## Introduction

## Conversation

### Dialog

**Sarah**: I’ve been working on the new `webhook integration`. It’s `event-driven`, so the external service will trigger the webhook when a specific action occurs.

**Will**: Nice! So, it sends a `POST request` to our endpoint?

**Sarah**: Exactly. The `payload` includes the data we need to process, and we `listen for the request` on a specific route.

**Will**: What about security? Are you using a signature to `verify the request`?

**Sarah**: Yes, the webhook sends a signature with the payload, and we validate it before processing."

**Will**: Sounds good. Have you `handled retries` in case of a `timeout` or error?"

**Sarah**: Yep, if the response isn’t `200 OK`, the `external service` retries the request a few times.

**Will**: Great. Let me know if there’s any issue with the `response handling.`

---

### Vocabulary

**POST request**

* **Definition:** A type of HTTP request used to send data to a server, typically used when submitting forms or sending data in APIs.
    
* **Portuguese:** Solicitação POST
    
* **Sample Sentences:**
    
    1. The external service sends a **POST request** to our server when the event occurs.
        
    2. We received a **POST request** with the necessary data to update the user profile.
        

---

**2\. Event-driven**

* **Definition:** A programming paradigm where actions are triggered by specific events or changes in state.
    
* **Portuguese:** Orientado a eventos
    
* **Sample Sentences:**
    
    1. The system is **event-driven**, so it only acts when a specific event happens.
        
    2. An **event-driven** architecture allows for better scalability when dealing with asynchronous tasks.
        

---

**3\. Verify the request**

* **Definition:** The process of checking whether a request is legitimate, often by validating its data or signature.
    
* **Portuguese:** Verificar a solicitação
    
* **Sample Sentences:**
    
    1. Before processing the webhook, we need to **verify the request** to ensure its authenticity.
        
    2. The system automatically **verifies the request** to prevent unauthorized access.
        

---

**4\. Webhook integration**

* **Definition:** The process of connecting external services via webhooks, where one service automatically sends data to another based on specific events.
    
* **Portuguese:** Integração de webhook
    
* **Sample Sentences:**
    
    1. The **webhook integration** allows us to receive real-time updates from the external service.
        
    2. Setting up the **webhook integration** was simple; it just required configuring the endpoint.
        

---

**5\. Response handling**

* **Definition:** The process of managing the response from a server after a request is made, including checking for errors or retries.
    
* **Portuguese:** Tratamento de resposta
    
* **Sample Sentences:**
    
    1. If the response is not 200 OK, we have custom **response handling** in place to manage retries.
        
    2. **Response handling** is critical to ensure the system can gracefully handle errors.
        

---

**6\. Payload**

* **Definition:** The data sent within the body of a request or response, often in JSON format.
    
* **Portuguese:** Dados enviados
    
* **Sample Sentences:**
    
    1. The **payload** includes all the necessary information for us to process the request.
        
    2. We parse the **payload** to extract the user’s details for further processing.
        

---

**7\. Handle retry**

* **Definition:** The process of attempting a request again after it fails, often due to network issues or timeouts.
    
* **Portuguese:** Lidar com tentativa
    
* **Sample Sentences:**
    
    1. If the webhook fails, we have a system in place to **handle retries** automatically.
        
    2. Our service can **handle retries** up to three times before stopping.
        

---

**8\. Timeout**

* **Definition:** A set time limit after which a request or process is stopped if no response is received.
    
* **Portuguese:** Tempo esgotado
    
* **Sample Sentences:**
    
    1. If the request doesn’t complete within the specified **timeout**, the service will retry.
        
    2. The **timeout** is set to 30 seconds, after which the system stops waiting for a response.
        

---

**9\. Listen for the request**

* **Definition:** To set up a system or endpoint to wait for and receive incoming requests from another service.
    
* **Portuguese:** Aguardar a solicitação
    
* **Sample Sentences:**
    
    1. Our endpoint is configured to **listen for the request** from the external service.
        
    2. The server will **listen for the request** and process the data as soon as it arrives.
        

---

**10\. Send a signature**

* **Definition:** The process of attaching a unique key or token to a request to verify its authenticity.
    
* **Portuguese:** Enviar uma assinatura
    
* **Sample Sentences:**
    
    1. The webhook will **send a signature** with the payload to confirm it’s from a trusted source.
        
    2. We validate the request by checking the signature the external service **sends**.
        

---

**11\. Trigger**

* **Definition:** To initiate or cause something to happen, such as an event or process.
    
* **Portuguese:** Acionar
    
* **Sample Sentences:**
    
    1. The external service will **trigger** the webhook when a specific action occurs.
        
    2. An event is **triggered** every time a user completes the registration process.
        

---

**12\. External service**

* **Definition:** A system or application outside of the current system that communicates via APIs or webhooks.
    
* **Portuguese:** Serviço externo
    
* **Sample Sentences:**
    
    1. The **external service** triggers the webhook when a user updates their profile.
        
    2. We rely on an **external service** to provide real-time notifications.
        

---

## Exercises

### Story telling

---

### Role play

\[POST request, event-driven, verify the request, webhook integration, response handling, payload, handle retry, timeout, listen for the request, send a signature, trigger, external service\]

---

### Personal experience

---

## Homework

### Reading comprehension

1. **What type of architecture does Sarah mention the webhook integration is based on?**
    
2. **What kind of request does the external service send to Sarah's system when an event occurs?**
    
3. **How does Sarah’s system verify the security of the webhook request?**
    
4. **What does the system do if the response to the webhook is not 200 OK?**
    
5. **What specific data is included in the webhook request according to Sarah?**
    

---

### Fill-in-the-Blanks

Complete the dialog using the words from the box below:

**\[POST request, event-driven, verify the request, webhook integration, response handling, payload, handle retry, timeout, listen for the request, send a signature, trigger, external service\]**

---

**Sarah:**  
I’ve been working on the new \_\_\_\_\_\_\_\_\_\_. It’s \_\_\_\_\_\_\_\_\_\_, so the \_\_\_\_\_\_\_\_\_\_ will \_\_\_\_\_\_\_\_\_\_ the webhook when a specific action occurs.

**Will:**  
Nice! So, it sends a \_\_\_\_\_\_\_\_\_\_ to our endpoint?

**Sarah:**  
Exactly. The \_\_\_\_\_\_\_\_\_\_ includes the data we need to process, and we \_\_\_\_\_\_\_\_\_\_ on a specific route.

**Will:**  
What about security? Are you using a signature to \_\_\_\_\_\_\_\_\_\_?

**Sarah:**  
Yes, the webhook will \_\_\_\_\_\_\_\_\_\_ with the payload, and we validate it before processing.

**Will:**  
Sounds good. Have you handled retries in case of a \_\_\_\_\_\_\_\_\_\_ or error?

**Sarah:**  
Yep, if the response isn’t 200 OK, the \_\_\_\_\_\_\_\_\_\_ service retries the request a few times.

**Will:**  
Great. Let me know if there’s any issue with the \_\_\_\_\_\_\_\_\_\_.

---

### Produce

**Create Your Own Dialog**

**Instructions:**

Using the 12 new words/expressions you’ve learned (**POST request, event-driven, verify the request, webhook integration, response handling, payload, handle retry, timeout, listen for the request, send a signature, trigger, external service**), create a dialog between two colleagues discussing a webhook integration they are implementing.

---

### **Partner Role Play**

For this exercise, you will practice using the vocabulary related to renting a car by acting out a role-play scenario.

You will need a partner for this activity, where one person will play the **customer** and the other person will play the **car rental agent**.

\[POST request, event-driven, verify the request, webhook integration, response handling, payload, handle retry, timeout, listen for the request, send a signature, trigger, external service\]

---

### **Personal experience**

**Instructions:**  
For this homework assignment, you will write a short story about your experience.

Write a short reflection (150-200 words) on your personal experience (real or imagined) with implementing or troubleshooting a webhook integration. Use the 12 new words/expressions from the vocabulary to describe the process and challenges you faced.

\[POST request, event-driven, verify the request, webhook integration, response handling, payload, handle retry, timeout, listen for the request, send a signature, trigger, external service\]

---

## Done

---
