Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 2f9947f

Browse files
JeffNaef-Trigermeshantoineco
authored andcommitted
Add doc for the Twilio target
Co-authored-by: Antoine Cotten <[email protected]>
1 parent b5ffcb5 commit 2f9947f

File tree

4 files changed

+42
-101
lines changed

4 files changed

+42
-101
lines changed
169 KB
Loading
122 KB
Loading

docs/targets/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Event Targets
22

3-
The following is a list of Triggermesh event Destinations known as Targets. Some are available as open source projects some are available as hosted solutions on our Cloud.
3+
The following is a list of Triggermesh event destinations known as `Targets`. Some are available as open source projects, some as hosted solutions on our Cloud.
44

55
## Current TriggerMesh Targets
66

77
* [AWS](./aws.md): Forward events to AWS services such as Lambda, SNS, SQS, and Kinesis.
88
* [AWS EventBridge](./awseventbridge.md): Forward arbitrary events to AWS EventBridge.
99
* [Elasticsearch](./elasticsearch.md): Send events to Elasticsarch to be indexed.
1010
* [Oracle](./oracle.md): Forward events to the Oracle Cloud.
11+
* [Twilio](./twilio.md): Send an SMS via Twilio in response to events.
1112
* [Slack](./slack.md): Forward events to Slack as messages to deliver immediately, scheduled, or as an update to a pre-existing message.
1213
* [Splunk](./splunk.md): Forward arbitrary events to Splunk.
1314
* [Zendesk](./zendesk.md): Perform actions in Zendesk upon reception of certain events.

docs/targets/twilio.md

Lines changed: 40 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,59 @@
1-
# Twilio event target for Knative Eventing
1+
# Event Target for Twilio
22

3-
This event target integrates with Twilio, using received Cloud Event messages to create SMS messages.
4-
5-
## Contents
6-
7-
- [Twilio event target for Knative Eventing](#twilio-event-target-for-knative-eventing)
8-
- [Contents](#contents)
9-
- [Prerequisites](#prerequisites)
10-
- [Controller Deployment](#controller-deployment)
11-
- [Kubernetes manifests](#kubernetes-manifests)
12-
- [From code](#from-code)
13-
- [Creating a Twilio Target](#creating-a-twilio-target)
14-
- [Status](#status)
15-
- [Twilio Target as an event Sink](#twilio-target-as-an-event-sink)
16-
- [Sending SMS to a Twilio Target](#sending-sms-to-a-twilio-target)
3+
This event Target receives [CloudEvents][ce] and utilizes [Twilio][landing] to enable the creation and delivery of SMS
4+
messages via event-data and event-occurrence, respectively.
175

186
## Prerequisites
197

20-
A Twilio account is required to run this target:
21-
22-
* Register a Twilio account
23-
* Purchase a phone number with
24-
* Retrieve from Twilio Dashbard Account SID
25-
* Retrieve from Twilio Dashbard Auth Token
26-
27-
## Controller Deployment
28-
29-
### Kubernetes manifests
30-
31-
// TODO use our images
32-
33-
### From code
34-
35-
You can use the [ko](https://github.com/google/ko) tool to compile and deploy from source.
36-
37-
```console
38-
ko create -f ./config
39-
```
40-
41-
## Creating a Twilio Target
42-
43-
Once the Twilio Target Controller has been deployed along all other needed assets are present we can create integrations by adding TwilioTargets objects.
44-
45-
```yaml
46-
apiVersion: targets.triggermesh.io/v1alpha1
47-
kind: TwilioTarget
48-
metadata:
49-
name: <TARGET-NAME>
50-
spec:
51-
defaultPhoneFrom: "<PHONE-FROM>"
52-
defaultPhoneTo: "<PHONE-TO>"
53-
sid:
54-
secretKeyRef:
55-
name: "<YOUR-SID-SECRET>"
56-
key: "<YOUR-SID-SECRET-KEY>"
57-
token:
58-
secretKeyRef:
59-
name: "<YOUR-TOKEN-SECRET>"
60-
key: "<YOUR-TOKEN-SECRET-KEY>"
61-
```
8+
1. [Twilio][try] account with access to the [Account SID][sid] & [Access Token][token].
9+
1. [Phone Number][pn].
6210

63-
Although `defaultPhoneFrom` is not mandatory you will usually configure it matching the phone number you have purchased at Twilio.
11+
## Deploying an Instance of the Target
6412

65-
On the other hand `defaultPhoneTo` wont be usually informed unless you want all messages to address the same phone number by default.
13+
Open the Bridge creation screen and add a Target of type `Twilio`.
6614

67-
Both configurations can be overrided at every Cloud Event message received at the Target.
15+
![Adding a Twilio Target](../images/twilio-target/create-bridge-1.png)
6816

69-
Refer to [Twilio docs for number formating](https://www.twilio.com/docs/lookup/tutorials/validation-and-formatting?code-sample=code-lookup-with-international-formatted-number).
17+
In the Target creation form, give a name to the event Target and add the following information:
7018

71-
### Status
19+
* **Default source phone number**: Sending phone number, usually configured to the [phone number][pn] purchased at
20+
Twilio. (Optional)
21+
* **Default destination**: Phone number to send messages to by default. (Optional)
22+
* **SID Secret**: Reference to a [TriggerMesh secret][tm-secret] containing the [SID of the Twilio account][sid].
23+
* **Token Secret**: Reference to a [TriggerMesh secret][tm-secret] containing an [API Access token][token] for
24+
authenticating requests against the Twilio API.
7225

73-
TwilioTarget requires two Secrets to be provided for SID and Token, once they are present it will create a Knative Service. Controller logs and events can provide detailed information about the process. A Status summary is added to the TwilioTarget object informing of the all conditions that the target needs.
26+
Both the **Default source phone number** and **Default destination** configurations may be overridden by any
27+
[CloudEvent][ce] message received by the Target.
7428

75-
When ready the `status.address.url` will point to the internal point where Cloud Events should be sent.
29+
For more information about using Twilio, please refer to the [Twilio documentation][docs].
7630

77-
### Twilio Target as an event Sink
31+
![Twilio Target form](../images/twilio-target/create-bridge-2.png)
7832

79-
Twilio Target is addressable, which means you can use it as a Sink for Knative components.
33+
After submitting the bridge, and allowing some configuration time, a green check mark on the main _Bridges_ page
34+
indicates that the bridge was successfully created.
8035

81-
```yaml
82-
apiVersion: eventing.knative.dev/v1beta1
83-
kind: Trigger
84-
metadata:
85-
name: <TRIGGER-NAME>
86-
spec:
87-
broker: <BROKER-NAME>
88-
filter:
89-
attributes:
90-
type: <MESSAGE-TYPES-TWILIO-FORMATTED>
91-
subscriber:
92-
ref:
93-
apiVersion: targets.triggermesh.io/v1alpha1
94-
kind: TwilioTarget
95-
name: <TARGET-NAME>
96-
```
36+
![Bridge status](../images/bridge-status-green.png)
9737

98-
### Sending SMS to a Twilio Target
38+
## Event Types
9939

100-
Twilio Target expect a JSON payload at the CloudEvent that includes:
40+
The Twilio event Target can consume events of any type, however, the Target expects a [JSON][ce-jsonformat] payload at
41+
the [CloudEvent][ce] with the following properties:
10142

102-
* `message`: text to be sent.
103-
* `media_urls`: array of URLs pointing to JPG, GIF or PNG resources.
104-
* `from`: phone sourcing the communication. Optional if provided by the TWilioTarget.
105-
* `to`: phone destination. Optional if provided by the TwilioTarget.
43+
| Name | Type | Description |
44+
|------|------|-------------|
45+
| **message** | string | Text to be sent in the body of the SMS message. |
46+
| **media_urls** | string | Array of URLs pointing to JPEG, GIF or PNG resources. |
47+
| **from** | string | Phone number sourcing the communication. Takes precedence over the value from the Twilio Target spec. |
48+
| **to** | string | Phone number of the destination. Takes precedence over the value from the Twilio Target spec. |
10649

107-
You can use `curl` from a container in the cluster pointing to the TwilioTarget exposed URL:
50+
[landing]: https://www.twilio.com/
51+
[try]: https://www.twilio.com/try-twilio
52+
[pn]: https://www.twilio.com/docs/phone-numbers
53+
[sid]: https://www.twilio.com/docs/iam/api/account
54+
[token]: https://www.twilio.com/docs/iam/access-tokens
55+
[docs]: https://www.twilio.com/docs
10856

109-
```console
110-
curl -v http://twiliotarget-int1-8dc3abc7d44bdd0130bd0a311bea272f.knative-samples.svc.cluster.local
111-
\
112-
-X POST \
113-
-H "Content-Type: application/json" \
114-
-H "Ce-Specversion: 1.0" \
115-
-H "Ce-Type: some.message.type" \
116-
-H "Ce-Source: some.origin/intance" \
117-
-H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f79" \
118-
-d '{"message":"Hello from Triggermesh using Twilio!","to": "+1111111111"}'
119-
```
57+
[ce]: https://cloudevents.io/
58+
[ce-jsonformat]: https://github.com/cloudevents/spec/blob/v1.0/json-format.md
59+
[tm-secret]: https://docs.triggermesh.io/guides/secrets/

0 commit comments

Comments
 (0)