# Skip integrations
Privileged users can skip integrations on a per-message basis, providing greater control and flexibility when publishing messages to a channel. Skipping integration helps avoid infinite loops, for example, when an integration republishes a message to the same channel, potentially triggering itself again.
A strong use case for skipping integrations is in chat applications. For example, a moderation service publishes a command telling clients to edit or delete a message. That command should not trigger further moderation events by itself.
## Skip all integrations
To skip all integration rules for a specific message, set the `skipRule` field to `'*'` in the `privileged` section of the message [`extras`](https://ably.com/docs/api/rest-sdk/messages.md#extras).
The following example shows how to skip all integration rules when publishing a message to a channel:
```javascript
const rest = new Ably.Rest('your-api-key');
const channel = rest.channels.get('your-channel-name');
await channel.publish({
name: 'event_name',
data: 'event_data',
extras: {
privileged: {
skipRule: '*'
}
}
});
```
```nodejs
const rest = new Ably.Rest('your-api-key');
const channel = rest.channels.get('your-channel-name');
await channel.publish({
name: 'event_name',
data: 'event_data',
extras: {
privileged: {
skipRule: '*'
}
}
});
```
```ruby
rest = Ably::Rest.new('your-api-key')
channel = rest.channels.get('your-channel-name')
while true
channel.publish 'event', 'data', extras: { { 'privileged' => { 'skipRule' => '*' } }
end
```
```python
rest = AblyRest('your-api-key')
channel = rest.channels.get('your-channel-name')
extras = {
"privileged": {
"skipRule": "*"
}
}
await channel.publish(Message(name='message', data="abc", extras=extras))
```
```php
$rest = new Ably\AblyRest('your-api-key');
$channel = $rest->channels->get('your-channel-name');
$channel->publish(
'event_name',
['field' => 'value'],
null,
[
'privileged' => [
'skipRule' => '*',
],
]
);
```
```java
AblyRest rest = new AblyRest("your-api-key");
Channel channel = rest.channels.get("your-channel-name");
// Using Google gson for JSON
String extrasJson = "{ \"privileged\": { \"skipRule\": \"*\" } }";
JsonObject extras = JsonParser.parseString(extrasJson).getAsJsonObject();
channel.publish(
new Message(
"event_name",
"event_data",
new MessageExtras(extras)
)
);
```
```csharp
AblyRest rest = new AblyRest("your-api-key");
var channel = rest.Channels.Get("your-channel-name");
// Using Newtonsoft for JSON
string extrasJson = @"{'privileged': { 'skipRule': '*' }}";
MessageExtras extras = new MessageExtras(extrasJson);
Message message = new Message("event", "data", null, extras);
channel.Publish(message);
```
```objc
ARTRest *rest = [[ARTRest alloc] initWithKey:@"your-api-key"];
ARTRestChannel *channel = [rest.channels get:@"your-channel-name"];
ARTJsonObject *extras = @{
@"privileged": @{@"skipRule": @"*"}
};
[channel publish:@"event" data:@"data" extras:extras];
```
```swift
let rest = ARTRest(key: "your-api-key")
let channel = rest.channels.get("your-channel-name")
let extras: NSDictionary = ["privileged": ["skipRule": "*"]]
channel.publish("event", data: "data", extras: extras as ARTJsonCompatible)
```
```go
rest, err := ably.NewREST(ably.WithKey("your-api-key"))
channel := rest.Channels.Get("your-channel-name")
privileged := make(map[string]string)
privileged["skipRule"] = "*"
extras := make(map[string]interface{})
extras["privileged"] = privileged
err := channel.PublishMultiple(context.Background(), []*ably.Message{
{Name: "event", Data: "data", Extras: extras},
})
```
## Skip specific integration rules
You can also skip specific integration rules by including their ruleId in an array passed to skipRule. Rule IDs can be found in the Integrations tab of your Ably [dashboard](https://ably.com/dashboard/any), via the Control API, or in the message envelope.
The following example shows how to skip specific integration rules when publishing a message to a channel:
```javascript
const rest = new Ably.Rest('your-api-key');
const channel = rest.channels.get('your-channel-name');
await channel.publish({
name: 'event_name',
data: 'event_data',
extras: {
privileged: { skipRule: ['rule_id_1'] }
}
})
```
```nodejs
const rest = new Ably.Rest('your-api-key');
const channel = rest.channels.get('your-channel-name');
await channel.publish({
name: 'event_name',
data: 'event_data',
extras: {
privileged: { skipRule: ['rule_id_1'] }
}
})
```
```ruby
rest = Ably::Rest.new('your-api-key')
channel = rest.channels.get('your-channel-name')
while true
channel.publish 'event', 'data', extras: { { 'privileged' => { 'skipRule' => ['rule_id_1'] } }
end
```
```python
rest = AblyRest('your-api-key')
channel = rest.channels.get('your-channel-name')
extras = {
"privileged": {
"skipRule": ["rule_id_1"]
}
}
await channel.publish(Message(name='message', data="abc", extras=extras))
```
```php
$rest = new Ably\AblyRest('your-api-key');
$channel = $rest->channels->get('your-channel-name');
$channel->publish(
'event_name',
['field' => 'value'],
null,
[
'privileged' => [
'skipRule' => ['rule_id_1'],
],
]
);
```
```java
AblyRest rest = new AblyRest("your-api-key");
Channel channel = rest.channels.get("your-channel-name");
// Using Google gson for JSON
String extrasJson = "{ \"privileged\": { \"skipRule\": [\"rule_id_1\"] } }";
JsonObject extras = JsonParser.parseString(extrasJson).getAsJsonObject();
channel.publish(
new Message(
"event_name",
"event_data",
new MessageExtras(extras)
)
);
```
```csharp
AblyRest rest = new AblyRest("your-api-key");
var channel = rest.Channels.Get("your-channel-name");
// Using Newtonsoft for JSON
string extrasJson = @"{'privileged': { 'skipRule': ['rule_id_1'] }}";
MessageExtras extras = new MessageExtras(extrasJson);
Message message = new Message("event", "data", null, extras);
channel.Publish(message);
```
```objc
ARTRest *rest = [[ARTRest alloc] initWithKey:@"your-api-key"];
ARTRestChannel *channel = [rest.channels get:@"your-channel-name"];
ARTJsonObject *extras = @{
@"privileged": @{@"skipRule": @[@"rule_id_1"]}
};
[channel publish:@"event" data:@"data" extras:extras];
```
```swift
let rest = ARTRest(key: "your-api-key")
let channel = rest.channels.get("your-channel-name")
let extras: NSDictionary = ["privileged": ["skipRule": ["rule_id_1"]]]
channel.publish("event", data: "data", extras: extras as ARTJsonCompatible)
```
```go
rest, err := ably.NewREST(ably.WithKey("your-api-key"))
channel := rest.Channels.Get("your-channel-name")
privileged := make(map[string][]string)
privileged["skipRule"] = []string{"rule_id_1"}
extras := make(map[string]interface{})
extras["privileged"] = privileged
err := channel.PublishMultiple(context.Background(), []*ably.Message{
{Name: "event", Data: "data", Extras: extras},
})
```