# External Initiators

### Overview

To better understand why we need External Initiators and what role they play, it's worth getting a better understanding of the Job Spec. The Job Spec conceptually consists of two parts:

* Initiator - When the Job is to be executed
* Task - How and in which order the Job is to be executed

Under the hood, Chainlink Node has a built-in set of Initiators and Tasks.\
If the built-in tools are not suitable for your task, the External Initiators and External Adapters come to the rescue.

### External Initiator

The External Initiator has a bi-directional action. This means that we can both send data to the client and receive data from the data sources.

For connected External Initiators, the Chainlink Node will notify them about the events of creating a new Job or deleting an existing Job whose whitelist contains a specific External Initiator.

<figure><img src="/files/dbaVu0d1TxPcE3lEYgCp" alt=""><figcaption><p>Example of External Initiator 1.1. Querying an external database and starting a Job according to specific criteria</p></figcaption></figure>

<figure><img src="/files/lIOSVVTWYTZVVCogtKHm" alt=""><figcaption><p>Example of External Initiator 1.2.0. Blockchain polling. Sending SMS messages to a client based on Blockchain events. Sending SMS messages to a client to create transactions on Blockchain</p></figcaption></figure>

<figure><img src="/files/ZxRC1YaTJVxRHQF8iE8B" alt=""><figcaption><p>Example of External Initiator 1.2.1 operation</p></figcaption></figure>

#### Creating External Initiator

The External Initiator is a service (e.g. written in go, nodejs, etc.) that must have a connection to the Postgres database (different from the database used by the Chainlink Node).

In order to communicate with the Job deployed on the Chainlink Node, the External Initiator must have cryptographic pairs:

* External Initiator Outgoing Access Key / External Initiator Outgoing Secret - To interact External Initiator → Chainlink Node
* External Initiator Incoming Access Key/External Initiator Incoming Secret - For interaction Chainlink Node → External Initiator

These pairs are automatically generated on the Chainlink Node side when you add the External Initiator. You will also need to add certain env variables to the External Initiator service after that.

#### Adding External Initiator to the Chainlink Node

The basic process is described in the documentation: <https://docs.chain.link/chainlink-nodes/external-initiators/external-initiators-in-nodes>

What you should pay attention to:

The .env file with variables like <mark style="color:orange;background-color:red;">`EI_*`</mark> must be plugged into the service that acts as the External Initiator.&#x20;

<mark style="background-color:red;">Important!</mark> The database specified in the variable <mark style="color:orange;">`EI_DATABASEURL`</mark> must be different from the Chainlink Node database.

### Sources

<https://docs.chain.link/chainlink-nodes/external-initiators/external-initiators-in-nodes>

<https://github.com/smartcontractkit/chainlink/wiki/External-Initiators>

<https://github.com/Conflux-Network-Global/demo-cfx-chainlink>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.oraclelabs.link/blog/articles/external-initiators.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
